Google Search - Blog...........

ABAP - Report Program To Retreive Custome PO & Statements.

DATA: it_statement TYPE TABLE OF bapi3007_2,

wa_statement LIKE LINE OF it_statement,

wa_stat LIKE LINE OF it_statement,

it_stat_po_invo TYPE TABLE OF (Table type of bapi3007_2),

wa_stat_po_invo LIKE LINE OF it_stat_po_invo,

it_vbrp TYPE TABLE OF st_vbrp(Structure containing ebeln and vebln),

wa_vbrp LIKE LINE OF it_vbrp.

CALL FUNCTION 'BAPI_AR_ACC_GETSTATEMENT'

EXPORTING

companycode = company_code

customer = customer_no

date_from = fromdate

date_to = todate

TABLES

lineitems = it_statement

.

LOOP AT it_statement INTO wa_statement.

MOVE-CORRESPONDING wa_statement TO wa_stat_po_invo.

APPEND wa_stat_po_invo TO it_stat_po_invo.

ENDLOOP.

IF it_stat_po_invo IS NOT INITIAL.

SELECT vbeln INTO CORRESPONDING FIELDS OF TABLE it_stat_po_invo

FROM bseg

FOR ALL ENTRIES IN it_stat_po_invo

WHERE

bukrs = company_code AND

belnr = it_stat_po_invo-doc_no AND

gjahr = it_stat_po_invo-fisc_year.

SELECT vbeln aubel aupos autyp INTO CORRESPONDING FIELDS OF TABLE it_vbrp

FROM vbrp

FOR ALL ENTRIES IN it_stat_po_invo

WHERE vbeln = it_stat_po_invo-vbeln.

SELECT bstnk INTO CORRESPONDING FIELDS OF TABLE it_vbrp

FROM vbak

FOR ALL ENTRIES IN it_vbrp

WHERE vbeln = it_vbrp-vbeln AND

vbtyp = 'V'.

LOOP AT it_stat_po_invo INTO wa_stat_po_invo.

LOOP AT it_vbrp INTO wa_vbrp.

IF wa_vbrp-vbeln = wa_stat_po_invo-vbeln.

wa_stat_po_invo-bstnk = wa_vbrp-bstnk.

MODIFY it_stat_po_invo FROM wa_stat_po_invo.

ENDIF.

ENDLOOP.

ENDLOOP.

ENDIF.

No comments:

Post a Comment