Skip to Content
0
Former Member
Dec 12, 2013 at 11:49 AM

want to append one row in final table

72 Views

Dear Friends,

i have one requirement,

i am retrieving data from BKPF and BSEG tables and appending in final table, right now i am getting two rows in final itab but i want only one row

please check below snap shots and also my code, could any one please give me the soloution

Advance Thanks

Vijaya

my final out put should be like 2nd row of final internal table

types : begin of ty_bkpf,

belnr type BELNR_D,

bldat type bldat,

budat type budat,

xblnr type XBLNR1,

bktxt type BKTXT,

waers type waers,

end of ty_bkpf.

data : lt_bkpf type TABLE OF ty_bkpf,

ls_bkpf type ty_bkpf.

TYPES : begin of ty_bseg,

belnr TYPE belnr_d,

fistl type fistl,

wrbtr type wrbtr,

lifnr type lifnr,

end of ty_bseg.

data : lt_bseg type table of ty_bseg,

ls_bseg type ty_bseg.

types : begin of ty_final,

belnr type BELNR_D,

bldat type bldat,

budat type budat,

xblnr type XBLNR1,

bktxt type BKTXT,

waers type waers,

fistl type fistl,

wrbtr type wrbtr,

lifnr type lifnr,

end of ty_final.

data : lt_final type table of ty_final,

ls_final type ty_final.

START-OF-SELECTION.

perform get_data.

PERFORM process_data.

perform disp_data.

*&---------------------------------------------------------------------*

*& Form GET_DATA

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM GET_DATA .

select belnr

bldat

budat

xblnr

bktxt

waers

from bkpf into table lt_bkpf WHERE belnr = '6000000079'.

if lt_bkpf is NOT INITIAL.

select belnr

fistl

wrbtr

lifnr from bseg into table lt_bseg FOR ALL ENTRIES IN lt_bkpf where belnr = lt_bkpf-belnr and lifnr = 'ACHPT9065K'.

endif.

ENDFORM. " GET_DATA

*&---------------------------------------------------------------------*

*& Form DISP_DATA

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM DISP_DATA .

loop at lt_final into ls_final.

write : / ls_final-bldat, ls_final-belnr, ls_final-budat, ls_final-waers, ls_final-xblnr, ls_final-bktxt, ls_final-lifnr, ls_final-fistl, ls_final-wrbtr.

ENDLOOP.

ENDFORM. " DISP_DATA

*&---------------------------------------------------------------------*

*& Form PROCESS_DATA

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM PROCESS_DATA .

loop at lt_bseg into ls_bseg.

ls_final-belnr = ls_bseg-belnr.

ls_final-wrbtr = ls_bseg-wrbtr.

ls_final-fistl = ls_bseg-fistl.

ls_final-lifnr = ls_bseg-lifnr.

append ls_final to lt_final.

READ TABLE lt_bkpf into ls_bkpf with key belnr = ls_bseg-belnr.

ls_final-bldat = ls_bkpf-bldat.

ls_final-budat = ls_bkpf-budat.

ls_final-xblnr = ls_bkpf-xblnr.

ls_final-bktxt = ls_bkpf-bktxt.

ls_final-waers = ls_bkpf-waers.

append ls_final to lt_final.

clear : ls_bkpf , ls_bseg, ls_final.

ENDLOOP.

ENDFORM.

Attachments

BKPF.jpg (39.0 kB)
BSEG.jpg (30.4 kB)
final1.jpg (69.1 kB)