Go to SE71 for design the form.
again de-select the graphical form painter.
clcik on font "Bold"
Click on standard
------------------------------------------------------------------
Now call the form through driver program
create a program in SE38.
REPORT ZDEMO_SCRIPTS.
TABLES: KNA1,
vbrk,
t001.
TYPES: BEGIN OF T_KNA1,
LAND1 TYPE KNA1-LAND1,
NAME1 TYPE KNA1-NAME1,
ORT01 TYPE KNA1-ORT01,
PSTLZ TYPE KNA1-PSTLZ,
STRAS TYPE KNA1-STRAS,
END OF T_KNA1.
TYPES: BEGIN OF T_T001,
BUTXT TYPE T001-BUTXT,
ORT01 TYPE T001-ORT01,
LAND1 TYPE T001-LAND1,
END OF T_T001.
TYPES: BEGIN OF T_VBRK,
VBELN TYPE VBRK-VBELN,
FKDAT TYPE VBRK-FKDAT,
WAERK TYPE VBRK-WAERK,
KUNAG TYPE KUNAG,
BUKRS TYPE BUKRS,
END OF T_VBRK.
TYPES: BEGIN OF T_VBRP,
VBELN TYPE VBELN,
NETWR TYPE VBRP-NETWR,
MATNR TYPE VBRP-MATNR,
ARKTX TYPE VBRP-ARKTX,
POSNR TYPE POSNR_VF,
END OF T_VBRP.
PARAMETERS:s_vbeln TYPE VBRK-vbeln.
TYPES: BEGIN OF T_FINAL,
VBELN TYPE VBRK-VBELN,
FKDAT TYPE VBRK-FKDAT,
WAERK TYPE VBRK-WAERK,
NETWR TYPE VBRP-NETWR,
MATNR TYPE VBRP-MATNR,
ARKTX TYPE VBRP-ARKTX,
POSNR TYPE POSNR_VF,
END OF T_FINAL.
DATA: IT_KNA1 TYPE TABLE OF T_KNA1,
WA_KNA1 TYPE T_KNA1,
IT_T001 TYPE TABLE OF T_T001,
WA_T001 TYPE T_T001,
IT_VBRK TYPE TABLE OF T_VBRK,
WA_VBRK TYPE T_VBRK,
IT_VBRP TYPE TABLE OF T_VBRP,
WA_VBRP TYPE T_VBRP,
IT_FINAL TYPE TABLE OF T_FINAL,
WA_FINAL TYPE T_FINAL.
Start-of-selection.
perform get_data.
PERFORM open_form.
PERFORM start_form.
PERFORM write_form.
PERFORM end_form.
PERFORM close_form.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text: Getting data into final internal table for display
*----------------------------------------------------------------------*
FORM GET_DATA.
select VBELN
FKDAT
WAERK
KUNAG
BUKRS
from VBRK INTO CORRESPONDING FIELDS OF TABLE IT_VBRK
WHERE VBELN = s_vbeln.
SELECT LAND1
NAME1
ORT01
PSTLZ
STRAS INTO CORRESPONDING FIELDS OF TABLE IT_KNA1 FROM KNA1 FOR ALL ENTRIES IN IT_VBRK WHERE KUNNR = IT_VBRK-KUNAG.
SELECT NETWR
MATNR
ARKTX
POSNR
VBELN
FROM VBRP INTO CORRESPONDING FIELDS OF TABLE IT_VBRP
FOR ALL ENTRIES IN IT_VBRK
WHERE VBELN = IT_VBRK-VBELN.
READ TABLE IT_VBRK INTO WA_VBRK INDEX 1.
IF SY-SUBRC = 0.
SELECT SINGLE BUTXT
ORT01
LAND1
FROM T001 INTO CORRESPONDING FIELDS OF WA_T001
WHERE BUKRS = WA_VBRK-BUKRS.
ENDIF.
* SELECT BUTXT
* ORT01
* LAND1
* FROM T001 INTO CORRESPONDING FIELDS OF TABLE IT_T001
* FOR ALL ENTRIES IN IT_VBRK
* WHERE BUKRS = IT_VBRK-BUKRS.
LOOP AT IT_VBRP INTO WA_VBRP.
READ TABLE IT_VBRK INTO WA_VBRK WITH KEY VBELN = WA_VBRP-VBELN.
IF SY-SUBRC = 0.
MOVE-CORRESPONDING WA_VBRK TO WA_FINAL.
MOVE-CORRESPONDING WA_VBRP TO WA_FINAL.
ENDIF.
APPEND WA_FINAL TO IT_FINAL.
ENDLOOP.
ENDFORM.
FORM OPEN_FORM.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = 'ZDEMO_SCRIPTS'.
ENDFORM.
FORM START_FORM.
CALL FUNCTION 'START_FORM'
EXPORTING
FORM = 'ZDEMO_SCRIPTS '.
ENDFORM.
FORM WRITE_FORM.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM_HEADER'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'MAIN'.
LOOP AT IT_FINAL INTO WA_FINAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM LINE'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'MAIN'.
ENDLOOP.
LOOP AT IT_KNA1 INTO WA_KNA1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'CUST_ADD'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'CUSTADDR'.
ENDLOOP.
* LOOP AT IT_T001 INTO WA_T001.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'OUR_ADD'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'OUR_ADDR'.
* ENDLOOP.
ENDFORM.
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.
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.
TABLES: KNA1,
vbrk,
t001.
TYPES: BEGIN OF T_KNA1,
LAND1 TYPE KNA1-LAND1,
NAME1 TYPE KNA1-NAME1,
ORT01 TYPE KNA1-ORT01,
PSTLZ TYPE KNA1-PSTLZ,
STRAS TYPE KNA1-STRAS,
END OF T_KNA1.
TYPES: BEGIN OF T_T001,
BUTXT TYPE T001-BUTXT,
ORT01 TYPE T001-ORT01,
LAND1 TYPE T001-LAND1,
END OF T_T001.
TYPES: BEGIN OF T_VBRK,
VBELN TYPE VBRK-VBELN,
FKDAT TYPE VBRK-FKDAT,
WAERK TYPE VBRK-WAERK,
KUNAG TYPE KUNAG,
BUKRS TYPE BUKRS,
END OF T_VBRK.
TYPES: BEGIN OF T_VBRP,
VBELN TYPE VBELN,
NETWR TYPE VBRP-NETWR,
MATNR TYPE VBRP-MATNR,
ARKTX TYPE VBRP-ARKTX,
POSNR TYPE POSNR_VF,
END OF T_VBRP.
PARAMETERS:s_vbeln TYPE VBRK-vbeln.
TYPES: BEGIN OF T_FINAL,
VBELN TYPE VBRK-VBELN,
FKDAT TYPE VBRK-FKDAT,
WAERK TYPE VBRK-WAERK,
NETWR TYPE VBRP-NETWR,
MATNR TYPE VBRP-MATNR,
ARKTX TYPE VBRP-ARKTX,
POSNR TYPE POSNR_VF,
END OF T_FINAL.
DATA: IT_KNA1 TYPE TABLE OF T_KNA1,
WA_KNA1 TYPE T_KNA1,
IT_T001 TYPE TABLE OF T_T001,
WA_T001 TYPE T_T001,
IT_VBRK TYPE TABLE OF T_VBRK,
WA_VBRK TYPE T_VBRK,
IT_VBRP TYPE TABLE OF T_VBRP,
WA_VBRP TYPE T_VBRP,
IT_FINAL TYPE TABLE OF T_FINAL,
WA_FINAL TYPE T_FINAL.
Start-of-selection.
perform get_data.
PERFORM open_form.
PERFORM start_form.
PERFORM write_form.
PERFORM end_form.
PERFORM close_form.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text: Getting data into final internal table for display
*----------------------------------------------------------------------*
FORM GET_DATA.
select VBELN
FKDAT
WAERK
KUNAG
BUKRS
from VBRK INTO CORRESPONDING FIELDS OF TABLE IT_VBRK
WHERE VBELN = s_vbeln.
SELECT LAND1
NAME1
ORT01
PSTLZ
STRAS INTO CORRESPONDING FIELDS OF TABLE IT_KNA1 FROM KNA1 FOR ALL ENTRIES IN IT_VBRK WHERE KUNNR = IT_VBRK-KUNAG.
SELECT NETWR
MATNR
ARKTX
POSNR
VBELN
FROM VBRP INTO CORRESPONDING FIELDS OF TABLE IT_VBRP
FOR ALL ENTRIES IN IT_VBRK
WHERE VBELN = IT_VBRK-VBELN.
READ TABLE IT_VBRK INTO WA_VBRK INDEX 1.
IF SY-SUBRC = 0.
SELECT SINGLE BUTXT
ORT01
LAND1
FROM T001 INTO CORRESPONDING FIELDS OF WA_T001
WHERE BUKRS = WA_VBRK-BUKRS.
ENDIF.
* SELECT BUTXT
* ORT01
* LAND1
* FROM T001 INTO CORRESPONDING FIELDS OF TABLE IT_T001
* FOR ALL ENTRIES IN IT_VBRK
* WHERE BUKRS = IT_VBRK-BUKRS.
LOOP AT IT_VBRP INTO WA_VBRP.
READ TABLE IT_VBRK INTO WA_VBRK WITH KEY VBELN = WA_VBRP-VBELN.
IF SY-SUBRC = 0.
MOVE-CORRESPONDING WA_VBRK TO WA_FINAL.
MOVE-CORRESPONDING WA_VBRP TO WA_FINAL.
ENDIF.
APPEND WA_FINAL TO IT_FINAL.
ENDLOOP.
ENDFORM.
FORM OPEN_FORM.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = 'ZDEMO_SCRIPTS'.
ENDFORM.
FORM START_FORM.
CALL FUNCTION 'START_FORM'
EXPORTING
FORM = 'ZDEMO_SCRIPTS '.
ENDFORM.
FORM WRITE_FORM.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM_HEADER'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'MAIN'.
LOOP AT IT_FINAL INTO WA_FINAL.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM LINE'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'MAIN'.
ENDLOOP.
LOOP AT IT_KNA1 INTO WA_KNA1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'CUST_ADD'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'CUSTADDR'.
ENDLOOP.
* LOOP AT IT_T001 INTO WA_T001.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'OUR_ADD'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'OUR_ADDR'.
* ENDLOOP.
ENDFORM.
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.
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.
-----------------------------------------------------------
execute it.
Done!..
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.