Dear gurus
I have a requirement of making SAPScript.
I have got two tables as
Header window
Main window
I am not getting all the records of Header table
but getting records of Main table.
what can be the fault .
can anyone tell
here's the code as
REPORT Z_KK_POSCRIPT.
TABLES: ekko,ekpo.
types: BEGIN OF t_ekko,
ebeln TYPE ekko-ebeln,
bedat TYPE ekko-bedat,
reswk TYPE ekko-reswk,
ekorg TYPE ekko-ekorg,
end of t_ekko.
types: BEGIN OF t_ekpo,
ebelp TYPE ekpo-ebelp,
txz01 TYPE ekpo-txz01,
menge TYPE ekpo-menge,
netpr TYPE ekpo-netpr,
ebeln TYPE ekpo-ebeln,
end of t_ekpo.
types: BEGIN OF t_final,
ebeln TYPE ekko-ebeln,
bedat TYPE ekko-bedat,
reswk TYPE ekko-reswk,
ekorg TYPE ekko-ekorg,
ebelp TYPE ekpo-ebelp,
txz01 TYPE ekpo-txz01,
menge TYPE ekpo-menge,
netpr TYPE ekpo-netpr,
v_total TYPE i,
end of t_final.
data: it_ekko TYPE STANDARD TABLE OF t_ekko,
wa_ekko TYPE t_ekko.
data: it_ekpo TYPE STANDARD TABLE OF t_ekpo,
wa_ekpo TYPE t_ekpo.
data: it_final TYPE STANDARD TABLE OF t_final,
wa_final TYPE t_final.
data: v_total TYPE i.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.
SELECT-OPTIONS: s_ebeln for ekko-ebeln.
SELECTION-SCREEN END OF BLOCK b1.
INITIALIZATION.
START-OF-SELECTION.
PERFORM get_data.
PERFORM open_form.
PERFORM start_form.
* PERFORM write_form.
PERFORM write_form1.
PERFORM end_form.
PERFORM close_form.
End-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form get_data.
Select ebeln bedat reswk ekorg
from ekko into TABLE it_ekko
where ebeln IN s_ebeln.
IF it_ekko is not INITIAL.
select ebelp txz01 menge netpr ebeln
from ekpo into table it_ekpo
FOR ALL ENTRIES IN it_ekko
where ebeln = it_ekko-ebeln.
loop at it_ekko into wa_ekko.
wa_final-ebeln = wa_ekko-ebeln.
wa_final-bedat = wa_ekko-bedat.
wa_final-reswk = wa_ekko-reswk.
wa_final-ekorg = wa_ekko-ekorg.
loop at it_ekpo INTO wa_ekpo where ebeln = wa_ekko-ebeln.
wa_final-ebelp = wa_ekpo-ebelp.
wa_final-txz01 = wa_ekpo-txz01.
wa_final-menge = wa_ekpo-menge.
wa_final-netpr = wa_ekpo-netpr.
v_total = wa_final-menge * wa_final-netpr.
wa_final-v_total = v_total.
APPEND wa_final to it_final.
clear wa_ekpo.
CLEAR wa_final.
endloop.
clear ekko.
endloop.
endif.
endform. "get_data
*&---------------------------------------------------------------------*
*& Form open_form
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form open_form.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = 'Z_KK_SCRIPT1'.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
endform. "open_form
*&---------------------------------------------------------------------*
*& Form start_form
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form start_form.
* loop at it_final into wa_final.
CALL FUNCTION 'START_FORM'
EXPORTING
FORM = 'Z_KK_SCRIPT1'.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
* endloop.
endform. "start_form
*&---------------------------------------------------------------------*
*& Form write_form
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
*form write_form.
*
** loop at it_final into wa_final.
** CALL FUNCTION 'WRITE_FORM'
** EXPORTING
** ELEMENT = 'ITEM HEADER'
*** FUNCTION = 'SET'
*** TYPE = 'BODY'
** WINDOW = 'HEADER'.
** IF SY-SUBRC <> 0.
*** Implement suitable error handling here
** ENDIF.
*** endloop.
*
* loop at it_final into wa_final.
* CALL FUNCTION 'WRITE_FORM'
* EXPORTING
* ELEMENT = 'HEADER'
** FUNCTION = 'SET'
** TYPE = 'BODY'
* WINDOW = 'HEADER'.
* IF SY-SUBRC <> 0.
** Implement suitable error handling here
* ENDIF.
* endloop.
*endform. "write_form
*&---------------------------------------------------------------------*
*& Form write1_form
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form write_form1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM HEADER '
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'MAIN'.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
loop at it_final into wa_final.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM LINE '
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'MAIN'.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
endloop.
endform. "write_form
*&---------------------------------------------------------------------*
*& Form end_form
*&---------------------------------------------------------------------*
* 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.
* Implement suitable error handling here
ENDIF.
endform. "end_form
*&---------------------------------------------------------------------*
*& Form close_form
*&---------------------------------------------------------------------*
* 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.
* Implement suitable error handling here
ENDIF.
endform.
Help.
Thanks
Regards
karan