Hello Experts
I have the following requirement in smartforms.
1. Need to design an invoice with the address details of the customer (KUNNR, LAND1, NAME1, NAME2, ORT01 and PSTLZ). This information needs to appear in the address window.
2. In the main window, I need to use the VBELN, MATNR, ARKTX, NETWR and KWMENG.
The Parameter for selection is the Sales Order Number (VBELN). When VBELN is entered, Address Window should be filled with fields mentioned in 1 and order related details mentioned in 2.
I created a final internal table and transferred all the fields to the IT_FINAL. Plz see the coding below:
*&---------------------------------------------------------------------*
*& Report ZPANKAJ_SMARTFORM2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZPANKAJ_SMARTFORM2 NO STANDARD PAGE HEADING.
TYPES: BEGIN OF TY_VBAK,
VBELN TYPE VBAK-VBELN,
KUNNR TYPE VBAK-KUNNR,
END OF TY_VBAK,
BEGIN OF TY_VBAP,
VBELN TYPE VBAP-VBELN,
MATNR TYPE VBAP-MATNR,
ARKTX TYPE VBAP-ARKTX,
NETWR TYPE VBAP-NETWR,
KWMENG TYPE VBAP-KWMENG,
END OF TY_VBAP,
BEGIN OF TY_KNA1,
KUNNR TYPE KNA1-KUNNR,
LAND1 TYPE KNA1-LAND1,
NAME1 TYPE KNA1-NAME1,
NAME2 TYPE KNA1-NAME2,
ORT01 TYPE KNA1-ORT01,
PSTLZ TYPE KNA1-PSTLZ,
END OF TY_KNA1,
BEGIN OF TY_FINAL,
VBELN TYPE VBAP-VBELN,
KUNNR TYPE VBAK-KUNNR,
MATNR TYPE VBAP-MATNR,
ARKTX TYPE VBAP-ARKTX,
NETWR TYPE VBAP-NETWR,
KWMENG TYPE VBAP-KWMENG,
LAND1 TYPE KNA1-LAND1,
NAME1 TYPE KNA1-NAME1,
NAME2 TYPE KNA1-NAME2,
ORT01 TYPE KNA1-ORT01,
PSTLZ TYPE KNA1-PSTLZ,
END OF TY_FINAL.
PARAMETERS: P_VBELN TYPE VBAK-VBELN.
DATA: IT_VBAK TYPE STANDARD TABLE OF TY_VBAK,
IT_VBAP TYPE STANDARD TABLE OF TY_VBAP,
IT_KNA1 TYPE STANDARD TABLE OF TY_KNA1,
IT_FINAL TYPE STANDARD TABLE OF TY_FINAL,
WA_VBAK TYPE TY_VBAK,
WA_VBAP TYPE TY_VBAP,
WA_KNA1 TYPE TY_KNA1,
WA_FINAL TYPE TY_FINAL.
DATA: LV_FNAME TYPE TDSFNAME.
AT SELECTION-SCREEN.
SELECT VBELN
KUNNR
FROM VBAK
INTO TABLE IT_VBAK
WHERE VBELN EQ P_VBELN.
IF SY-SUBRC NE 0.
MESSAGE 'ENTER A VALID VALUE' TYPE 'E'.
ENDIF.
SELECT VBELN
MATNR
ARKTX
NETWR
KWMENG
FROM VBAP
INTO TABLE IT_VBAP
WHERE VBELN EQ P_VBELN.
START-OF-SELECTION.
IF NOT IT_VBAK IS INITIAL.
SELECT KUNNR
LAND1
NAME1
NAME2
ORT01
PSTLZ
FROM KNA1
INTO TABLE IT_KNA1
FOR ALL ENTRIES IN IT_VBAK
WHERE KUNNR = IT_VBAK-KUNNR.
ENDIF.
LOOP AT IT_VBAP INTO WA_VBAP.
IF SY-SUBRC EQ 0.
MOVE: WA_VBAP-VBELN TO WA_FINAL-VBELN,
WA_VBAP-MATNR TO WA_FINAL-MATNR,
WA_VBAP-ARKTX TO WA_FINAL-ARKTX,
WA_VBAP-NETWR TO WA_FINAL-NETWR,
WA_VBAP-KWMENG TO WA_FINAL-KWMENG.
ENDIF.
READ TABLE IT_VBAK INTO WA_VBAK WITH KEY VBELN = WA_VBAP-VBELN.
IF SY-SUBRC EQ 0.
MOVE: WA_VBAK-KUNNR TO WA_FINAL-KUNNR.
ENDIF.
READ TABLE IT_KNA1 INTO WA_KNA1 WITH KEY KUNNR = WA_VBAK-KUNNR.
IF SY-SUBRC EQ 0.
MOVE: WA_KNA1-LAND1 TO WA_FINAL-LAND1,
WA_KNA1-NAME1 TO WA_FINAL-NAME1,
WA_KNA1-NAME2 TO WA_FINAL-NAME2,
WA_KNA1-ORT01 TO WA_FINAL-ORT01,
WA_KNA1-PSTLZ TO WA_FINAL-PSTLZ.
ENDIF.
APPEND WA_FINAL TO IT_FINAL.
CLEAR: WA_VBAK, WA_VBAP, WA_KNA1, WA_FINAL.
ENDLOOP.
Note: When the program was ran in debugging mode, all the fields were in IT_FINAL.
Now, in the smartform, when I enter IT_FINAL under interfaces, I get an error saying the IT_FINAL is not a structure. I tried all possible ways, trial and error methods but have not been successful. I have also tried using the Global Definitions but to not success.
Can anyone tell me if how to use the interfaces or the global definitions if using the concept of Final Internal Table in smartforms as I have been told that it is the best approach.
Looking forward to your help.
Regards
Bidyut