REPORT ZDEMO_SAPSCRIPT_PERFORM.
*----------------------------------------------------------------------
* TABLES: VBAP. TABLES: ITCPO. " optional for setting default print parameters PARAMETERS: FORM LIKE RSSCF-TDFORM DEFAULT 'YDEMO_PERFORM'.
START-OF-SELECTION.
************************************************************************
* Open the SapScript Form with the "form" * ************************************************************************
CLEAR ITCPO .
* itcpo-tddest = 'ZHTM'.
ITCPO-TDIMMED = 'X'.
ITCPO-TDDELETE = 'X'.
ITCPO-TDNEWID = 'X'.
CALL FUNCTION 'OPEN_FORM'
EXPORTING FORM = FORM " name of form (SE71)
OPTIONS = ITCPO
EXCEPTIONS CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
MAIL_OPTIONS = 6
OTHERS = 7. ************************************************************************ *
* Execute the element "HELLO" in window MAIN *
- Nothing happens if /E HELLO is not declared in MAIN ************************************************************************
CALL FUNCTION 'WRITE_FORM'
EXPORTING ELEMENT = 'HELLO' "execute element /E HELLO * FUNCTION = 'SET'
TYPE = 'BODY' "normal output
EXCEPTIONS ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
OTHERS = 8. ************************************************************************
* Close the current SapScript Form ************************************************************************
CALL FUNCTION 'CLOSE_FORM'
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
OTHERS = 3.
FORM CALLED_FROM_SAPSCRIPT TABLES IN_TAB STRUCTURE ITCSY OUT_TAB STRUCTURE ITCSY.
DATA: TABIX LIKE SY-TABIX.
TABLES: KNA1.
BREAK-POINT.
READ TABLE IN_TAB WITH KEY NAME = 'KUNNR'.
KNA1-KUNNR = IN_TAB-VALUE.
READ TABLE OUT_TAB WITH KEY NAME = 'NAME'.
TABIX = SY-TABIX.
OUT_TAB-NAME = 'NAME'.
SELECT SINGLE * FROM KNA1 WHERE KUNNR EQ KNA1-KUNNR.
IF SY-SUBRC EQ 0.
CONCATENATE KNA1-NAME1 KNA1-ORT01 INTO OUT_TAB-VALUE SEPARATED BY SPACE.
ELSE.
CONCATENATE KNA1-KUNNR 'not found' INTO OUT_TAB-VALUE SEPARATED BY SPACE.
ENDIF.
MODIFY OUT_TAB INDEX TABIX.
ENDFORM.
....+....1....+....2....+....3....+....4....+....5....+....6....+....7.. /E PERFORM_ABAP /: PERFORM CALLED_FROM_SAPSCRIPT IN PROGRAM zsapscriptexits /: USING &invar1& /: USING &invar2& ... /: CHANGING &outvar1& /: CHANGING &outvar2& ... /: ENDPERFORM
(Refer from site idocs.de)
No comments:
Post a Comment