Sie sind auf Seite 1von 16

A

B A P&W E B D Y N P R O A B A P @ A R J U N

IGROWSOFT

A Classical report 1 with all EVENTS as per Real time Programming


Business Requirement : Develop a CUSTOMER Master Report
to display Custno,country,name1,city
REPORT

ZCLASSICAL_REP1 NO STANDARD PAGE HEADING LINE-COUNT 26(3).

TYPES: BEGIN OF TY_KNA1,


KUNNR TYPE KNA1-KUNNR,
LAND1 TYPE KNA1-LAND1,
NAME1 TYPE KNA1-NAME1,
ORT01 TYPE KNA1-ORT01,
END OF TY_KNA1.
DATA
DATA
DATA
DATA
DATA

:
:
:
:
:

I_KNA1 TYPE TABLE OF TY_KNA1 .


WA_KNA1 TYPE TY_KNA1 .
V_TITLE(25) TYPE
C .
V_LAND1 TYPE KNA1-LAND1 .
V_FNAME TYPE STRING .

********************SELECTION SCREEN
PARAMETERS : P_LAND1 TYPE KNA1-LAND1 .
PARAMETERS : P_FNAME TYPE RLGRAP-FILENAME .
PARAMETERS : P_DLOAD AS CHECKBOX .

INITIALIZATION .
PERFORM INIT_VARIBALES.
*AT SELECTION-SCREEN OUTPUT .
AT SELECTION-SCREEN ON P_LAND1.
PERFORM VALIDATE_LAND1 .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
PERFORM GET_FILE_NAME .
*
AT SELECTION-SCREEN ON HELP-REQUEST FOR P_FNAME .
PERFORM GET_HELP .
*AT SELECTION-SCREEN .
START-OF-SELECTION .
PERFORM GET_DATA .
END-OF-SELECTION .

AR J U N.LE ARN R E AL T I ME SC E N ARIOS DON E B Y ME

Page 1

B A P&W E B D Y N P R O A B A P @ A R J U N

IGROWSOFT

IF P_DLOAD = 'X' .
PERFORM DOWNLOAD_DATA .
ENDIF .
PERFORM DISPLAY_DATA .
TOP-OF-PAGE .
PERFORM DISPLAY_HEADING .
END-OF-PAGE .
PERFORM DISPLAY_FOOTER .
*&---------------------------------------------------------------------*
*&
Form INIT_VARIBALES
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM INIT_VARIBALES .
V_TITLE = 'CUSTOMER MASTER REPORT' .
P_LAND1 = 'DE' .
ENDFORM.
" INIT_VARIBALES
*&---------------------------------------------------------------------*
*&
Form VALIDATE_LAND1
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM VALIDATE_LAND1 .
SELECT LAND1
FROM KNA1
INTO V_LAND1
UP TO 1 ROWS
WHERE LAND1 = P_LAND1.
ENDSELECT .
IF SY-SUBRC <> 0 .
MESSAGE 'INVALID COUNTRY CODE' TYPE 'E' .
ENDIF .
ENDFORM.
" VALIDATE_LAND1

AR J U N.LE ARN R E AL T I ME SC E N ARIOS DON E B Y ME

Page 2

B A P&W E B D Y N P R O A B A P @ A R J U N

IGROWSOFT

*&---------------------------------------------------------------------*
*&
Form GET_DATA
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM GET_DATA .
SELECT KUNNR LAND1 NAME1 ORT01
FROM KNA1
INTO TABLE I_KNA1
WHERE LAND1 = P_LAND1 .
IF SY-SUBRC <> 0 .
MESSAGE 'NO DATA FOUND' TYPE 'I' .
ENDIF .
ENDFORM.
" GET_DATA
*&---------------------------------------------------------------------*
*&
Form DISPLAY_HEADING
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM DISPLAY_HEADING .
WRITE : / SY-ULINE .
WRITE : /45 V_TITLE COLOR 5 .
WRITE : / SY-ULINE .
ENDFORM.
" DISPLAY_HEADING
*&---------------------------------------------------------------------*
*&
Form DISPLAY_FOOTER
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM DISPLAY_FOOTER .
WRITE : / SY-ULINE .
WRITE : /45 'IBM INDIA PVT.LTD' COLOR 5 .
WRITE : / SY-ULINE .
ENDFORM.
" DISPLAY_FOOTER

AR J U N.LE ARN R E AL T I ME SC E N ARIOS DON E B Y ME

Page 3

B A P&W E B D Y N P R O A B A P @ A R J U N

IGROWSOFT

*&---------------------------------------------------------------------*
*&
Form DISPLAY_DATA
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM DISPLAY_DATA .
LOOP AT I_KNA1 INTO WA_KNA1 .
WRITE : / WA_KNA1-KUNNR , WA_KNA1-LAND1 , WA_KNA1-NAME1 , WA_KNA1ORT01 .
ENDLOOP .
ENDFORM.
" DISPLAY_DATA
*&---------------------------------------------------------------------*
*&
Form DOWNLOAD_DATA
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM DOWNLOAD_DATA .
V_FNAME = P_FNAME .
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME
= V_FNAME "'C:\KNA1.TXT'
FILETYPE
= 'DAT' "ASC MEANS NOTEPAD FILE/DAT MEASN EXCEL F
ILE
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB
= I_KNA1.
.
IF SY-SUBRC = 0.
MESSAGE 'DATA IS SUCCESSFULLY DOWNLOADED' TYPE 'I'.
ENDIF.
ENDFORM.
" DOWNLOAD_DATA

AR J U N.LE ARN R E AL T I ME SC E N ARIOS DON E B Y ME

Page 4

B A P&W E B D Y N P R O A B A P @ A R J U N

IGROWSOFT

*&---------------------------------------------------------------------*
*&
Form GET_FILE_NAME
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM GET_FILE_NAME .
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME
= 'P_FNAME'
CHANGING
FILE_NAME
= P_FNAME.
IF SY-SUBRC <> 0.
ENDIF.
ENDFORM.
" GET_FILE_NAME
*&---------------------------------------------------------------------*
*&
Form GET_HELP
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM GET_HELP .
MESSAGE 'PLEASE CLCIIK ON F4 FOR FILE NAME' TYPE 'I'.
ENDFORM.
" GET_HELP

AR J U N.LE ARN R E AL T I ME SC E N ARIOS DON E B Y ME

Page 5

B A P&W E B D Y N P R O A B A P @ A R J U N

IGROWSOFT

A Classical report2 with Select-options as per Real time Programming


Business requirement : Develop a material master report
to display Mat.No,Type,Ind.Sector,Units
TYPES : BEGIN OF TY_MARA,
MATNR TYPE MARA-MATNR,
MTART TYPE MARA-MTART,
MBRSH TYPE MARA-MBRSH,
MEINS TYPE MARA-MEINS,
END OF TY_MARA.
DATA :
DATA :
DATA :
DATA :
DATA :
TABLES

I_MARA TYPE TABLE OF TY_MARA .


WA_MARA TYPE TY_MARA .
V_TITLE(25) TYPE
C .
V_MTART TYPE MARA-MTART .
V_FNAME TYPE STRING .
: MARA .

********************SELECTION SCREEM
SELECT-OPTIONS : SO_MATNR FOR MARA-MATNR .
PARAMETERS : P_MTART TYPE MARA-MTART .
PARAMETERS : P_FNAME TYPE RLGRAP-FILENAME .
PARAMETERS : P_DLOAD AS CHECKBOX .
INITIALIZATION .
PERFORM INIT_VARIBALES.
*AT SELECTION-SCREEN OUTPUT .
AT SELECTION-SCREEN ON P_MTART.
PERFORM VALIDATE_MTART .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
PERFORM GET_FILE_NAME .
*
AT SELECTION-SCREEN ON HELP-REQUEST FOR P_FNAME .
PERFORM GET_HELP .
AT SELECTION-SCREEN .
PERFORM VALIDATE_MTART .

AR J U N.LE ARN R E AL T I ME SC E N ARIOS DON E B Y ME

Page 6

B A P&W E B D Y N P R O A B A P @ A R J U N

IGROWSOFT

START-OF-SELECTION .
PERFORM GET_DATA .
END-OF-SELECTION .

IF P_DLOAD = 'X' .
PERFORM DOWNLOAD_DATA .
ENDIF .
PERFORM DISPLAY_DATA .
TOP-OF-PAGE .
PERFORM DISPLAY_HEADING .
END-OF-PAGE .
PERFORM DISPLAY_FOOTER .

*&---------------------------------------------------------------------*
*&
Form INIT_VARIBALES
*&---------------------------------------------------------------------*
*
text
*--------------------------------------------------------------------- -*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM INIT_VARIBALES .
V_TITLE = 'MATERIAL MASTER REPORT' .
P_MTART = 'FERT' .
SO_MATNR-SIGN = 'I' .
SO_MATNR-OPTION = 'BT' .
SO_MATNR-LOW = '1' .
SO_MATNR-HIGH = '1000' .
APPEND SO_MATNR .
ENDFORM.

" INIT_VARIBALES

AR J U N.LE ARN R E AL T I ME SC E N ARIOS DON E B Y ME

Page 7

B A P&W E B D Y N P R O A B A P @ A R J U N

IGROWSOFT

*&---------------------------------------------------------------------*
*&
Form VALIDATE_LAND1
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM VALIDATE_MTART .
SELECT MTART
FROM MARA
INTO V_MTART
UP TO 1 ROWS
WHERE MTART = P_MTART.
ENDSELECT .
IF SY-SUBRC <> 0 .
MESSAGE 'INVALID MATERIAL TYPE' TYPE 'E' .
ENDIF .
ENDFORM.
" VALIDATE_LAND1

*&---------------------------------------------------------------------*
*&
Form GET_DATA
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM GET_DATA .
SELECT MATNR MTART MBRSH MEINS
FROM MARA
INTO TABLE I_MARA
WHERE MATNR IN SO_MATNR
AND
MTART = P_MTART .
IF SY-SUBRC <> 0 .
MESSAGE 'NO DATA FOUND' TYPE 'I' .
ENDIF .
ENDFORM.
" GET_DATA

AR J U N.LE ARN R E AL T I ME SC E N ARIOS DON E B Y ME

Page 8

B A P&W E B D Y N P R O A B A P @ A R J U N

IGROWSOFT

*&---------------------------------------------------------------------*
*&
Form DISPLAY_HEADING
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM DISPLAY_HEADING .
WRITE : / SY-ULINE .
WRITE : /45 V_TITLE COLOR 5 .
WRITE : / SY-ULINE .
ENDFORM.
" DISPLAY_HEADING
*&---------------------------------------------------------------------*
*&
Form DISPLAY_FOOTER
*&---------------------------------------------------------------------*
*
text
*--------------------------------------------------------------------- -*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM DISPLAY_FOOTER .
WRITE : / SY-ULINE .
WRITE : /30 'ALL RIGHTS RESERVED TO OUR COMPNAY ARJUN INDUSTRIES INDIA PVT
.LTD' COLOR 5 .
WRITE : / SY-ULINE .
ENDFORM.
" DISPLAY_FOOTER
*&---------------------------------------------------------------------*
*&
Form DISPLAY_DATA
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM DISPLAY_DATA .
LOOP AT I_MARA INTO WA_MARA .
WRITE : / WA_MARA-MATNR , WA_MARA-MTART , WA_MARA-MBRSH , WA_MARAMEINS .
ENDLOOP .
ENDFORM.
" DISPLAY_DATA

AR J U N.LE ARN R E AL T I ME SC E N ARIOS DON E B Y ME

Page 9

B A P&W E B D Y N P R O A B A P @ A R J U N

IGROWSOFT

*&---------------------------------------------------------------------*
*&
Form DOWNLOAD_DATA
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM DOWNLOAD_DATA .
V_FNAME = P_FNAME .
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME
= V_FNAME "'C:\MARA.TXT'
FILETYPE
= 'DAT' "ASC MEANS NOTEPAD FILE/DAT MEANS EXCEL
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB
= I_MARA.
IF SY-SUBRC = 0.
MESSAGE 'DATA IS SUCCESSFULLY DOWNLOADED' TYPE 'I'.
ENDIF.
ENDFORM.
" DOWNLOAD_DATA
*&---------------------------------------------------------------------*
*&
Form GET_FILE_NAME
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM GET_FILE_NAME .
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME
= 'P_FNAME'
CHANGING
FILE_NAME
= P_FNAME.
IF SY-SUBRC <> 0.
ENDIF.
ENDFORM.

" GET_FILE_NAME

AR J U N.LE ARN R E AL T I ME SC E N ARIOS DON E B Y ME

Page 10

B A P&W E B D Y N P R O A B A P @ A R J U N

IGROWSOFT

*&---------------------------------------------------------------------*
*&
Form GET_HELP
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM GET_HELP .
MESSAGE 'PLEASE CLCIIK ON F4 FOR FILE NAME' TYPE 'I'.
ENDFORM.
" GET_HELP

Save->act->Test.
The Selection-Screen will be displayed with default values which is our requirement.

AR J U N.LE ARN R E AL T I ME SC E N ARIOS DON E B Y ME

Page 11

B A P&W E B D Y N P R O A B A P @ A R J U N

IGROWSOFT

A Classical report3 to modify Selection-Screen Dynamically as per


Real time Programming
PARAMETERS : P_KUNNR
P_KNAME
P_LIFNR
P_VNAME

TYPE
TYPE
TYPE
TYPE

KNA1-KUNNR
KNA1-NAME1
LFA1-LIFNR
LFA1-NAME1

MODIF
MODIF
MODIF
MODIF

ID
ID
ID
ID

AAA,
AAA,
BBB,
BBB .

PARAMETERS : RB_CUST RADIOBUTTON GROUP RB1 DEFAULT 'X' USER-COMMAND UCOMM,


RB_VEND RADIOBUTTON GROUP RB1 .
AT SELECTION-SCREEN OUTPUT .
IF RB_CUST = 'X' .
LOOP AT SCREEN .
IF SCREEN-GROUP1 = 'AAA'.
SCREEN-INPUT = '1'.
MODIFY SCREEN .
ELSEIF SCREEN-GROUP1 = 'BBB'.
SCREEN-INPUT = '0'.
MODIFY SCREEN .
ENDIF .
ENDLOOP .
ELSEIF RB_VEND = 'X' .
LOOP AT SCREEN .
IF SCREEN-GROUP1 = 'AAA'.
SCREEN-INPUT = '0'.
MODIFY SCREEN .
ELSEIF SCREEN-GROUP1 = 'BBB'.
SCREEN-INPUT = '1'.
MODIFY SCREEN .
ENDIF .
ENDLOOP .
ENDIF .

Save->Act->Test

AR J U N.LE ARN R E AL T I ME SC E N ARIOS DON E B Y ME

Page 12

B A P&W E B D Y N P R O A B A P @ A R J U N

IGROWSOFT

Since customer radio button is selected, The KUNNR &KNAME are


enabled.

Since Vendor radio button is selected, The LIFNR &VNAME are


enabled.

AR J U N.LE ARN R E AL T I ME SC E N ARIOS DON E B Y ME

Page 13

B A P&W E B D Y N P R O A B A P @ A R J U N

IGROWSOFT

A Classical report4 to differentiate AT SS ON FIELD & AT SS


as per Real time Programming
Using AT SS ON FIELD
TYPES : BEGIN OF TY_VBAK,
VBELN TYPE VBAK-VBELN,
VKORG TYPE VBAK-VKORG,
VTWEG TYPE VBAK-VTWEG,
SPART TYPE VBAK-SPART,
END OF TY_VBAK.
DATA :
TABLES
DATA :
DATA :
DATA :

I_VBAK TYPE TABLE OF TY_VBAK.


: VBAK.
V_VKORG TYPE VBAK-VKORG .
V_VTWEG TYPE VBAK-VTWEG .
V_SPART TYPE VBAK-SPART .

SELECT-OPTIONS : SO_VBELN
PARAMETERS : P_VKORG TYPE
PARAMETERS : P_VTWEG TYPE
PARAMETERS : P_SPART TYPE

FOR VBAK-VBELN .
VBAK-VKORG .
VBAK-VTWEG.
VBAK-SPART .

AT SELECTION-SCREEN ON P_VKORG .
PERFORM VALIDATE_VKORG .
AT SELECTION-SCREEN ON P_VTWEG .
PERFORM VALIDATE_VTWEG .
AT SELECTION-SCREEN ON P_SPART .
PERFORM VALIDATE_SPART .
START-OF-SELECTION .
END-OF-SELECTION .

AR J U N.LE ARN R E AL T I ME SC E N ARIOS DON E B Y ME

Page 14

B A P&W E B D Y N P R O A B A P @ A R J U N

IGROWSOFT

*&---------------------------------------------------------------------*
*&
Form VALIDATE_VKORG
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM VALIDATE_VKORG .
SELECT VKORG
FROM VBAK
INTO V_VKORG
UP TO 1 ROWS
WHERE VKORG = P_VKORG.
ENDSELECT .
IF SY-SUBRC <> 0 .
MESSAGE 'INVALID SALES ORG' TYPE 'E' .
ENDIF .
ENDFORM.
" VALIDATE_VKORG
*&---------------------------------------------------------------------*
*&
Form VALIDATE_VTWEG
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM VALIDATE_VTWEG .
SELECT VTWEG
FROM VBAK
INTO V_VTWEG
UP TO 1 ROWS
WHERE VTWEG = P_VTWEG.
ENDSELECT .
IF SY-SUBRC <> 0 .
MESSAGE 'INVALID DIST.CHANNEL' TYPE 'E' .
ENDIF .
ENDFORM.
" VALIDATE_VTWEG

AR J U N.LE ARN R E AL T I ME SC E N ARIOS DON E B Y ME

Page 15

B A P&W E B D Y N P R O A B A P @ A R J U N

IGROWSOFT

*&---------------------------------------------------------------------*
*&
Form VALIDATE_SPART
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM VALIDATE_SPART .
SELECT SPART
FROM VBAK
INTO V_SPART
UP TO 1 ROWS
WHERE SPART = P_SPART.
.
ENDSELECT .
IF SY-SUBRC <> 0 .
MESSAGE 'INVALID DIVISION' TYPE 'E' .
ENDIF .
ENDFORM.

" VALIDATE_SPART

Save->Act->Test
Using AT SS for Multiple Fields Validation
Same prog as above with below change
AT SELECTION-SCREEN .
PERFORM VALIDATE_VKORG .
PERFORM VALIDATE_VTWEG .
PERFORM VALIDATE_SPART .
START-OF-SELECTION .
END-OF-SELECTION .

Save->Act->Test->and observe the difference


Final Words By Me:

AR J U N.LE ARN R E AL T I ME SC E N ARIOS DON E B Y ME

Page 16