Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

hi need urgent

CASE r_ucomm.

WHEN 'CREATE'.

int_result1[] = int_result[].

SORT int_result1 BY lifnr.

DELETE ADJACENT DUPLICATES FROM int_result1 COMPARING lifnr.

LOOP AT int_result1.

describe table int_result lines loc_count.

loc_count1 = loc_count / 500.

LOOP AT int_result WHERE lifnr = int_result1-lifnr .

loc_total_amount = loc_total_amount + int_result-curr_amount .

counter = counter + 1.

int_bapi_item_data-invoice_doc_item = counter.

int_bapi_item_data-po_number = int_result-ebeln.

int_bapi_item_data-po_item = int_result-ebelp.

int_bapi_item_data-tax_code = 'E0'.

int_bapi_item_data-item_amount = int_result-curr_amount.

APPEND int_bapi_item_data.

acc_data-invoice_doc_item = counter.

acc_data-xunpl = 'X'.

acc_data-tax_code = 'E0'.

acc_data-item_amount = int_result-curr_amount.

acc_data-gl_account = '0009900001'.

APPEND acc_data.

ENDLOOP.

wf_bapi_header_data-invoice_ind = 'X'.

wf_bapi_header_data-doc_type = 'RE'.

wf_bapi_header_data-doc_date = sy-datum.

wf_bapi_header_data-pstng_date = sy-datum.

CONCATENATE P_ipABrp p_ipabrj sy-datum sy-uzeit INTO

wf_bapi_header_data-ref_doc_no.

wf_bapi_header_data-comp_code = '1000'.

wf_bapi_header_data-gross_amount = loc_total_amount .

CALL FUNCTION 'Y_INVOICE_CREATE' DESTINATION wa_destination

EXPORTING

headerdata = wf_bapi_header_data

IMPORTING

invoicedocnumber = wf_belnr

fiscalyear = wf_gjahr

TABLES

itemdata = int_bapi_item_data

accountingdata = acc_data

return = int_bapi_return_messages.

  • ENDLOOP.

IF sy-subrc = 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

CLEAR : wf_bapi_header_data,

loc_total_amount,

counter,

int_bapi_return_messages.

REFRESH: int_bapi_item_data,

acc_data,

int_bapi_return_messages.

ELSE.

LOOP AT int_bapi_return_messages.

WRITE:/05 int_bapi_return_messages-type,

10 int_bapi_return_messages-id,

15 int_bapi_return_messages-number,

20 int_bapi_return_messages-message.

ENDLOOP.

ENDIF.

ENDLOOP.

ENDCASE.

ENDFORM.

hi all

in my first loop, lifnr is there.

for each vendor , i may be having no of line items. but i want to create invoice ,ie

i have to call bapi after it reaches thes 500 th line items.

if ia m having 1200 line item, i have to call 3 times the bapi to craete invoice.

for 500 items i yhave to create one INVOICE.

what is the logic i have to add in my coding?

urgent plz

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question