Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

entries missing...

Former Member
0 Likes
991

Below is my code...table GT_BKPF1 contains 4 entries for a given BELNR...it is showing only the last entry...at the bottom im writing the modifying stament is it correct? i want all entries from GT_BKPF1 to be displayed...

LOOP AT gt_reptab INTO gw_reptab.

lv_tabix = sy-tabix.

LOOP AT gt_detail INTO gw_detail WHERE belnr = gw_reptab-docnum

AND bukrs = gw_reptab-ccode.

*----


UHDK932263

*----Interval months: DBMON From BKDF

SELECT SINGLE DBMON INTO LV_DBMON FROM BKDF

WHERE bukrs EQ gW_reptab-ccode

AND dbbdt EQ gW_reptab-fir_run

AND BELNR EQ gw_reptab-docnum.

GW_REPTAB-DBMON = LV_DBMON.

*----FOR VENDOR FULL NAME

SELECT SINGLE NAME1 INTO LV_NAME1 FROM LFA1

WHERE LIFNR = GW_DETAIL-LIFNR.

GW_REPTAB-NAME1 = LV_NAME1.

*----


BKPF-BELNR MAY HAVE MULTIPLE ENTRIES

*--FOR BELNR IN BKPF-INVOICE DOCUMENT

SELECT SINGLE BELNR INTO LV_BELNR FROM BKPF

WHERE DBBLG EQ gw_reptab-docnum

AND bukrs EQ gW_reptab-ccode

AND GJAHR EQ gW_reptab-fyear.

*

GW_REPTAB-BELNR = LV_BELNR.

SELECT BELNR BUKRS GJAHR FROM BKPF INTO TABLE GT_BKPF1

WHERE DBBLG EQ gw_reptab-docnum

AND bukrs EQ gw_reptab-ccode

AND GJAHR EQ gw_reptab-fyear.

SELECT belnr BUDAT FROM BKPF INTO TABLE GT_BUDAT1

FOR ALL ENTRIES IN GT_BKPF1

WHERE BELNR EQ GT_BKPF1-BELNR

AND bukrs EQ gT_BKPF1-BUKRS

AND GJAHR EQ gT_BKPF1-GJAHR.

*----


*LOOP FOR BKPF FOR MULTIPLE ENTIRES

LOOP AT GT_BKPF1 INTO GWA_BKPF1.

GW_REPTAB-BELNR = GWA_BKPF1-BELNR.

LOOP AT GT_BUDAT1 INTO GWA_BUDAT1.

READ TABLE GT_BUDAT1 INTO GWA_BUDAT1

WITH KEY BELNR = GWA_BKPF1-BELNR.

GW_REPTAB-BUDAT = GWA_BUDAT1-BUDAT.

*---IF INVOICE NUMBER IS NULL THEN FOLLOWING ENTRIES WILL BE NULL

IF GW_REPTAB-BELNR = ' '.

MOVE ' ' TO LV_DBMON .

MOVE ' ' TO LV_NAME1.

MOVE ' ' TO LV_BELNR.

MOVE ' ' TO LV_BUDAT.

MOVE ' ' TO LV_WRBTR.

MOVE ' ' TO LV_AUGBL.

MOVE ' ' TO LV_AUGDT.

MOVE ' ' TO LV_WRBTR1.

MOVE ' ' TO LV_KOSTL.

MOVE ' ' TO LV_AUFNR.

MOVE ' ' TO LV_HKONT.

MOVE ' ' TO LV_PROJK.

ELSE.

-----DOUBT

**--FOR BUDAT IN BKPF-POSTING DATE

SELECT SINGLE BUDAT INTO LV_BUDAT FROM BKPF

WHERE BELNR EQ gw_reptab-docnum

AND bukrs EQ gW_reptab-ccode

AND GJAHR EQ gW_reptab-fyear.

*

GW_REPTAB-BUDAT = LV_BUDAT.

*--FOR WRBTR IN BSEG-INVOICE AMOUNT

SELECT SINGLE WRBTR INTO LV_WRBTR FROM BSEG

WHERE bukrs EQ gW_reptab-ccode

AND BELNR EQ gw_reptab-docnum

AND GJAHR EQ gW_reptab-fyear.

GW_REPTAB-WRBTR = LV_WRBTR.

*--FOR WRBTR IN BSEG-INVOICE AMOUNT

SELECT SINGLE AUGBL INTO LV_AUGBL FROM BSEG

WHERE bukrs EQ gW_reptab-ccode

AND BELNR EQ gw_reptab-docnum

AND GJAHR EQ gW_reptab-fyear.

GW_REPTAB-AUGBL = LV_AUGBL.

*--FOR WRBTR IN BSEG-INVOICE AMOUNT

SELECT SINGLE AUGDT INTO LV_AUGDT FROM BSEG

WHERE bukrs EQ gW_reptab-ccode

AND BELNR EQ gw_reptab-docnum

AND GJAHR EQ gW_reptab-fyear.

GW_REPTAB-AUGDT = LV_AUGDT.

*--FOR WRBTR IN BSEG-CLEARING AMOUNT

IF GW_REPTAB-AUGBL EQ ' '.

MOVE ' ' TO GW_REPTAB-WRBTR1.

ELSE.

SELECT SINGLE WRBTR INTO LV_WRBTR1 FROM BSEG

WHERE AUGBL EQ gW_reptab-AUGBL

WHERE BELNR EQ GW_REPTAB-AUGBL.

AND GJAHR EQ gW_reptab-fyear.

GW_REPTAB-WRBTR1 = LV_WRBTR1.

ENDIF.

*-----COST CENTRE FROM BSEG

SELECT SINGLE KOSTL INTO LV_KOSTL FROM BSEG

WHERE bukrs EQ gW_reptab-ccode

AND BELNR EQ gw_reptab-docnum

AND GJAHR EQ gW_reptab-fyear

AND SHKZG EQ 'S'.

GW_REPTAB-KOSTL = LV_KOSTL.

*-----Order FROM BSEG

SELECT SINGLE AUFNR INTO LV_AUFNR FROM BSEG

WHERE bukrs EQ gW_reptab-ccode

AND BELNR EQ gw_reptab-docnum

AND GJAHR EQ gW_reptab-fyear

AND SHKZG EQ 'S'.

GW_REPTAB-AUFNR = LV_AUFNR.

*-----G/L Account FROM BSEG

SELECT SINGLE HKONT INTO LV_HKONT FROM BSEG

WHERE bukrs EQ gW_reptab-ccode

AND BELNR EQ gw_reptab-docnum

AND GJAHR EQ gW_reptab-fyear

AND SHKZG EQ 'S'.

GW_REPTAB-HKONT1 = LV_HKONT.

*-----WBS Element FROM BSEG

SELECT SINGLE PROJK INTO LV_PROJK FROM BSEG

WHERE bukrs EQ gW_reptab-ccode

AND BELNR EQ gw_reptab-docnum

AND GJAHR EQ gW_reptab-fyear

AND SHKZG EQ 'S'.

GW_REPTAB-PROJK = LV_PROJK.

*----


GW_REPTAB-BUDAT = GW_DETAIL-BUDAT.

ENDIF. " BELNR IS NOT NULL

ENDLOOP.

*----


UHDK932263

IF gw_detail-koart = 'K'.

gw_reptab-lifnr = gw_detail-lifnr.

ELSEIF gw_detail-koart = 'S'.

gw_reptab-hkont = gw_detail-hkont.

ENDIF.

gw_reptab-ttl_pstamt = gw_detail-dmbtr * gw_reptab-docs.

ENDLOOP.

SELECT * FROM t054a INTO TABLE gt_t054a

WHERE dbakz = gw_reptab-dbakz.

DESCRIBE TABLE gt_t054a LINES length_t054a.

IF NOT ( length_t054a EQ 0 ).

gw_reptab-ttl_docamt = gw_detail-dmbtr * length_t054a.

ELSE.

CLEAR lv_moths.

CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES_NEW'

EXPORTING

i_datum_bis = gw_reptab-las_run

i_datum_von = gw_reptab-fir_run

i_kz_incl_bis = ' '

i_kz_volle_monate = 'X'

IMPORTING

e_monate = lv_moths.

gw_reptab-ttl_docamt = ( lv_moths + 1 ) * gw_detail-dmbtr.

ENDIF.

MODIFY GT_BKPF1 FROM GWA_BKPF1 TRANSPORTING BELNR .

*----


UHDK932263

MODIFY gt_reptab FROM gw_reptab INDEX lv_tabix

TRANSPORTING lifnr hkont ttl_docamt ttl_pstamt

BELNR BUDAT DBMON NAME1 WRBTR AUGBL AUGDT WRBTR1

KOSTL AUFNR HKONT1 PROJK.

*----


UHDK932263

CLEAR : gw_reptab, gw_detail, GWA_BKPF1, GWA_BUDAT1.

CLEAR : LV_DBMON, LV_NAME1, LV_BELNR, LV_BUDAT, LV_WRBTR, LV_AUGBL,

LV_AUGDT, LV_WRBTR1, LV_KOSTL, LV_AUFNR, LV_HKONT, LV_PROJK.

ENDLOOP.

ENDLOOP.

ENDLOOP.

6 REPLIES 6
Read only

Former Member
0 Likes
809

I bet this program will run nice and fast in a production environment. I await you next post of: -

'Performance issue'....

Read only

0 Likes
809

leave about the performance issue...i want the values GT_BKPF1 to be populated...

Read only

0 Likes
809

and put code "snippets" inside tags to provide better readabilty.

Read only

0 Likes
809

do i need to write any append statement?? as the values are not appended to gt_reptab...

Read only

Former Member
0 Likes
809

Ravi,

In finding of your entry from your program i found myself missing in meanwhile in your program,can you pls debug and take me out from your THREE nested loop?

Cheers

Read only

Former Member
0 Likes
809

Ravi - performance will likely be such a big issue that it's pointless to try to figure out what is wrong with it now. I would re-write it from the top; doing that may help you analyze your other problem.

Rob