ABAP/4
ABAP/4 Example Code: How to apply CONTROL_FORM function in ABAP/4
Example
START-OF-SELECTION.
PERFORM OPEN_FORM.
PERFORM START_FORM.
PERFORM WRITE_FORM USING ’LINE1’. "Define LINE1 element name in MAIN
PERFORM CONTROL_FORM USING ’NEW-PAGE’.
PERFORM WRITE_FORM USING ’LINE2’. "Define LINE2 element name in MAIN
PERFORM END_FORM.
PERFORM CLOSE_FORM.
*&---------------------------------------------------------------------*
*& Form OPEN_FORM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM OPEN_FORM .
CALL FUNCTION ’OPEN_FORM’
* EXPORTING
* APPLICATION = ’TX’
* ARCHIVE_INDEX =
* ARCHIVE_PARAMS =
* DEVICE = ’PRINTER’
* DIALOG = ’X’
* FORM = ’ ’
* LANGUAGE = SY-LANGU
* OPTIONS =
* MAIL_SENDER =
* MAIL_RECIPIENT =
* MAIL_APPL_OBJECT =
* RAW_DATA_INTERFACE = ’*’
* SPONUMIV =
* IMPORTING
* LANGUAGE =
* NEW_ARCHIVE_PARAMS =
* RESULT =
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
MAIL_OPTIONS = 6
ARCHIVE_ERROR = 7
INVALID_FAX_NUMBER = 8
MORE_PARAMS_NEEDED_IN_BATCH = 9
SPOOL_ERROR = 10
CODEPAGE = 11
OTHERS = 12
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " OPEN_FORM
*&---------------------------------------------------------------------*
*& Form START_FORM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM START_FORM .
CALL FUNCTION ’START_FORM’
EXPORTING
* ARCHIVE_INDEX =
FORM = ’ZFORM001’
* LANGUAGE = ’ ’
* STARTPAGE = ’ ’
* PROGRAM = ’ ’
* MAIL_APPL_OBJECT =
* IMPORTING
* LANGUAGE =
EXCEPTIONS
FORM = 1
FORMAT = 2
UNENDED = 3
UNOPENED = 4
UNUSED = 5
SPOOL_ERROR = 6
CODEPAGE = 7
OTHERS = 8
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " START_FORM
*&---------------------------------------------------------------------*
*& Form CLOSE_FORM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CLOSE_FORM .
CALL FUNCTION ’CLOSE_FORM’
* IMPORTING
* RESULT =
* RDI_RESULT =
* TABLES
* OTFDATA =
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
SPOOL_ERROR = 4
CODEPAGE = 5
OTHERS = 6
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " CLOSE_FORM
*&---------------------------------------------------------------------*
*& Form END_FORM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM END_FORM .
CALL FUNCTION ’END_FORM’
* IMPORTING
* RESULT =
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SPOOL_ERROR = 3
CODEPAGE = 4
OTHERS = 5
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " END_FORM
*&---------------------------------------------------------------------*
*& Form WRITE_FORM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM WRITE_FORM USING ELEMENT_NAME.
CALL FUNCTION ’WRITE_FORM’
EXPORTING
ELEMENT = ELEMENT_NAME
* FUNCTION = ’SET’
* TYPE = ’BODY’
* WINDOW = ’MAIN’
* IMPORTING
* PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
CODEPAGE = 9
OTHERS = 10
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " WRITE_FORM
*&---------------------------------------------------------------------*
*& Form CONTROL_FORM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CONTROL_FORM USING command.
CALL FUNCTION ’CONTROL_FORM’
EXPORTING
COMMAND = command
EXCEPTIONS
UNOPENED = 1
UNSTARTED = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " CONTROL_FORM
- thitima's blog
- Add new comment
- Read more
- 2978 reads
How to set cursor field on selection-screen in ABAP/4
You can set cursor field on selection-screen by applying statement ’SET CURSOR FIELD ...’ in event INITIALIZATION.
Example
PARAMETERS: P_FLD1(20) TYPE C,
P_FLD2 TYPE I.
INITIALIZATION.
SET CURSOR FIELD ’P_FLD2’.
The output is:
- thitima's blog
- 1 comment
- Read more
- 7801 reads
How to create parameter as listbox in ABAP/4
You can create parameter as listbox by applying statement ’PARAMETER
Example
TYPE-POOLS: vrm.
DATA: it_list TYPE VRM_VALUES,
list_value TYPE VRM_VALUE.
PARAMETERS: p_list(20) TYPE C AS LISTBOX VISIBLE LENGTH 15.
AT SELECTION-SCREEN OUTPUT.
list_value-key = ’AAAA’.
list_value-text = ’AAAA Show Text’.
append list_value to it_list.
list_value-key = ’AAAB’.
list_value-text = ’AAAB Show Text’.
append list_value to it_list.
list_value-key = ’AAAC’.
list_value-text = ’AAAC Show Text’.
append list_value to it_list.
list_value-key = ’AAAD’.
list_value-text = ’AAAD Show Text’.
append list_value to it_list.
CALL FUNCTION ’VRM_SET_VALUES’
EXPORTING
ID = ’P_LIST’
VALUES = it_list
EXCEPTIONS
ID_ILLEGAL_NAME = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
START-OF-SELECTION.
WRITE:/ ’P_LIST parameter have value: ’, p_list.
- thitima's blog
- Add new comment
- Read more
- 7991 reads
Create pushbutton in selection screen in ABAP/4
You can create the pushbutton in your selection screen by applying statement ’SELECTION-SCREEN PUSHBUTTON ...’.
Example
TABLES sscrfields.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
PARAMETERS: p_fld1 TYPE i DEFAULT 1,
p_fld2 TYPE i DEFAULT 2.
SELECTION-SCREEN PUSHBUTTON /1(10) Execute USER-COMMAND EXEC.
SELECTION-SCREEN END OF BLOCK b1.
INITIALIZATION.
Execute = ’Testing’.
AT SELECTION-SCREEN.
IF sscrfields-ucomm = ’EXEC’.
MESSAGE I398(00) WITH ’Testing Pushbutton Action between value’
p_fld1 ’and’ p_fld2.
ENDIF.The output is:
When you select the pushbutton, the output is:
- thitima's blog
- Add new comment
- Read more
- 8476 reads
ABAP/4 Example Code: How to generate graph 3D by ABAP/4
We can generate graph 3D by applying function module ’GRAPH_3D’.
Example
DATA: BEGIN OF itab OCCURS 0,
text(20) TYPE C,
value1 TYPE i,
value2 TYPE i,
value3 TYPE i,
END OF itab.
START-OF-SELECTION.
itab-text = ’COL1’.
itab-value1 = ’20’.
itab-value2 = ’5’.
itab-value3 = ’10’.
APPEND itab.
itab-text = ’COL2’.
itab-value1 = ’5’.
itab-value2 = ’15’.
itab-value3 = ’30’.
APPEND itab.
itab-text = ’COL3’.
itab-value1 = ’80’.
itab-value2 = ’50’.
itab-value3 = ’40’.
APPEND itab.
itab-text = ’COL4’.
itab-value1 = ’35’.
itab-value2 = ’15’.
itab-value3 = ’5’.
APPEND itab.
CALL FUNCTION ’GRAPH_3D’
EXPORTING
* AUTO_CMD_1 = ’ ’
* AUTO_CMD_2 = ’ ’
* DIM1 = ’ ’
* DIM2 = ’ ’
* TYPE = ’ ’
* DISPLAY_TYPE = ’ ’
* INBUF = ’ ’
* INFORM = ’ ’
* MAIL_ALLOW = ’ ’
* PWDID = ’ ’
* SET_FOCUS = ’x’
* SO_CONTENTS = ’ ’
* SO_RECEIVER = ’ ’
* SO_SEND = ’ ’
* SO_TITLE = ’ ’
* STAT = ’ ’
* SUPER = ’ ’
* TIMER = ’ ’
TITL = ’Testing graph 3D’
* VALT = ’ ’
* WDID = ’ ’
* WINID = ’ ’
* WINPOS = ’ ’
* WINSZX = ’50’
* WINSZY = ’50’
* X_OPT = ’ ’
* NOTIFY = ’ ’
* IMPORTING
* B_KEY =
* B_TYP =
* CUA_ID =
* MOD_COL =
* MOD_ROW =
* MOD_VAL =
* M_TYP =
* RBUFF =
* RWNID =
TABLES
DATA = itab
.
- thitima's blog
- Add new comment
- Read more
- 1678 reads
ABAP/4 Example Code: How to generate graph 2D by ABAP/4
We can generate graph 2D by applying function module ’GRAPH_2D’.
Example
DATA: BEGIN OF itab OCCURS 0,
text(20) TYPE C,
value TYPE i,
END OF itab.
START-OF-SELECTION.
itab-text = ’COL1’.
itab-value = 50.
APPEND itab.
itab-text = ’COL2’.
itab-value = 100.
APPEND itab.
itab-text = ’COL3’.<
- thitima's blog
- Add new comment
- Read more
- 2700 reads
Recent comments
3 years 29 weeks ago
3 years 34 weeks ago
3 years 35 weeks ago
3 years 35 weeks ago
3 years 36 weeks ago
3 years 38 weeks ago
3 years 38 weeks ago
3 years 38 weeks ago
3 years 38 weeks ago
3 years 38 weeks ago