CALL MULTIPLE LAYOUTS FROM THE SAME DRIVER PROGRAM IN SAP SCRIPTS

CALL MULTIPLE LAYOUTS FROM THE SAME DRIVER PROGRAM IN SAP SCRIPTS:

Steps to call the multiple layouts from driver program:-

1. Create an executable program & implement the retrieving logic.
2. Access the layout from driver program by using 'OPEN_FORM' function module.
3.
     A. Start the form by using 'START_FORM' function module. The input for the above function
          module is form name.
     B. Transfer the data from driver program to particular page window by using 'WRITE_FORM'
          function module. The input for the above function module is window name. Repeat the
          same step B for each page window which contains program symbols.
     C. End the form by using 'END_FORM' function module.

     Repeat the step 3 for each form.
4. Close the form by using 'CLOSE_FORM' function module.

DRIVER PROGRAM:

*&-------------------------------------------------------------------*
*& Report  ZD_CALL_MULTI_LAYOUTS
*&
*&-------------------------------------------------------------------*
REPORT ZD_CALL_MULTI_LAYOUTS.
PARAMETER P_EBELN TYPE EKPO-EBELN.
TYPESBEGIN OF TY_EKPO,
 EBELN 
TYPE EKPO-EBELN,
 EBELP 
TYPE EKPO-EBELP,
 MENGE 
TYPE EKPO-MENGE,
 MEINS 
TYPE EKPO-MEINS,
 NETPR 
TYPE EKPO-NETPR,
 
END OF TY_EKPO.
DATAWA_EKPO TYPE TY_EKPO,
 IT_EKPO 
TYPE TABLE OF TY_EKPO.
DATA V_TOTAL TYPE EKPO-NETPR.
PARAMETER P_LIFNR TYPE LFA1-LIFNR.
TYPESBEGIN OF TY_LFA1,
 LIFNR 
TYPE LFA1-LIFNR,
 NAME1 
TYPE LFA1-NAME1,
 ORT01 
TYPE LFA1-ORT01,
 
END OF TY_LFA1.
DATA WA_LFA1 TYPE TY_LFA1.
SELECT SINGLE LIFNR NAME1 ORT01 
       FROM LFA1 
       INTO WA_LFA1 
       WHERE LIFNR P_LIFNR.
SELECT EBELN EBELP MENGE MEINS NETPR
       
FROM EKPO
       
INTO TABLE IT_EKPO
       
WHERE EBELN P_EBELN.
* Start the form
CALL FUNCTION 'OPEN_FORM'.
* Start form for the first layout
CALL FUNCTION 'START_FORM'
 
EXPORTING
 
FORM 'ZF_BOX_COMMAND'.
*Print the data on header window
CALL FUNCTION 'WRITE_FORM'
 
EXPORTING
 
WINDOW 'HEADER'.
*Print the data on main window
LOOP AT IT_EKPO INTO WA_EKPO.
 
CALL FUNCTION 'WRITE_FORM'
 
EXPORTING
 ELEMENT 
'AM'
 
WINDOW 'MAIN'.

V_TOTAL 
V_TOTAL + WA_EKPO-NETPR.
ENDLOOP.
CALL FUNCTION 'END_FORM'.                     " END FIRST FORM
* Start form for the second layout
CALL FUNCTION 'START_FORM'
 
EXPORTING
 
FORM 'ZF_SCRIPT1'.
* Transfer the data to address window.
CALL FUNCTION 'WRITE_FORM'
 
EXPORTING
 
WINDOW 'ADDRESS'.
* LOGO window.
CALL FUNCTION 'WRITE_FORM'
 
EXPORTING
 
WINDOW 'LOGO'.
CALL FUNCTION 'END_FORM'.                    " END SECOND FORM
*Close the form
CALL FUNCTION 'CLOSE_FORM'.


INPUT:



OUTPUT:

First form output is printed in first page.




Second form output is printed in second page.