Application Development 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: 

Difference between Tcode ML81N and BAPI_ENTRYSHEET_CREATE?

Former Member
0 Kudos
352

<b></b><b></b>

Hi SAP Gurus,

We are trying to create Goods receipt for Service items in PO. Currently we are using Function module BAPI_ENTRYSHEET_CREATE. This Function module creates Entry sheet and its corresponding Material documents..The material documents created thru bapi are not equal to SERIAL_NO in accounting assignment at PO item level(ie; material

documents are created more than the

Account assignment summarized lines).But same item

created thru Tcode ML81N,giving equal number of material documents with its corresponding SERIAL_NO....

(ie; material

documents are created equal to the

Account assignment summarized lines)

can any body tell me why this difference happening ....?

Your help highly appreciated..

Regards

Dinesh.A

5 REPLIES 5

Former Member
0 Kudos
92

I think the BAPI is not called with proper data. I am also doing the same thing, its working fine.

Check the sample code:

&----


*& Report YPRA_SAMPLE42 *

*& *

&----


*& *

*& *

&----


REPORT ypra_sample42.

DATA: wa_header TYPE bapiessrc,

i_return TYPE bapiret2 OCCURS 0 WITH HEADER LINE,

ws_entrysheet_no TYPE bapiessr-sheet_no,

i_service TYPE bapiesllc OCCURS 0 WITH HEADER LINE,

i_service_acc TYPE bapiesklc OCCURS 0 WITH HEADER LINE,

i_service_text TYPE bapieslltx OCCURS 0 WITH HEADER LINE,

i_account TYPE bapiesknc OCCURS 0 WITH HEADER LINE,

ws_pack_no TYPE packno.

DATA: ws_po TYPE bapiekko-po_number,

po_items TYPE bapiekpo OCCURS 0 WITH HEADER LINE,

po_services TYPE bapiesll OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF wa_po_header OCCURS 1.

INCLUDE STRUCTURE bapiekkol.

DATA: END OF wa_po_header.

DATA: BEGIN OF bapi_return_po OCCURS 1.

INCLUDE STRUCTURE bapireturn.

DATA: END OF bapi_return_po.

DATA: serial_no LIKE bapiesknc-serial_no,

line_no LIKE bapiesllc-line_no.

DATA: bapi_esll LIKE bapiesllc OCCURS 1

WITH HEADER LINE.

ws_po = '4300000066'.

CALL FUNCTION 'BAPI_PO_GETDETAIL'

EXPORTING

purchaseorder = ws_po

items = 'X'

services = 'X'

IMPORTING

po_header = wa_po_header

TABLES

po_items = po_items

po_item_services = po_services

return = bapi_return_po.

wa_header-po_number = po_items-po_number.

wa_header-po_item = po_items-po_item.

wa_header-short_text = 'Sample'.

wa_header-acceptance = 'X'.

wa_header-doc_date = sy-datum.

wa_header-post_date = sy-datum.

wa_header-pckg_no = 1.

serial_no = 0.

line_no = 1.

bapi_esll-pckg_no = 1.

bapi_esll-line_no = line_no.

bapi_esll-outl_level = '0'.

bapi_esll-outl_ind = 'X'.

bapi_esll-subpckg_no = 2.

APPEND bapi_esll.

LOOP AT po_services WHERE NOT short_text IS INITIAL.

line_no = line_no + 1.

CLEAR bapi_esll.

  • MOVE-CORRESPONDING po_services TO bapi_esll.

  • bapi_esll-gr_price = '456'.

bapi_esll-pckg_no = 2.

bapi_esll-line_no = line_no.

bapi_esll-service = po_services-service.

bapi_esll-quantity = po_services-quantity.

bapi_esll-gr_price = po_services-gr_price.

bapi_esll-price_unit = po_services-price_unit.

APPEND bapi_esll.

ENDLOOP.

CALL FUNCTION 'BAPI_ENTRYSHEET_CREATE'

EXPORTING

entrysheetheader = wa_header

  • testrun = 'X'

IMPORTING

entrysheet = ws_entrysheet_no

TABLES

  • ENTRYSHEETACCOUNTASSIGNMENT =

entrysheetservices = bapi_esll

  • entrysheetsrvaccassvalues = i_service_acc

return = i_return

  • entrysheetservicestexts = i_service_text

  • ENTRYSHEETHEADERTEXT =

.

break gbpra8.

LOOP AT i_return.

ENDLOOP.

DATA: ws_wait TYPE bapita-wait.

ws_wait = '3'.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = ws_wait.

*CALL FUNCTION 'BAPI_ENTRYSHEET_RELEASE'

  • EXPORTING

  • entrysheet = ws_entrysheet_no

  • rel_code =

    • TABLES

    • RETURN =

.

0 Kudos
92

Hi Prakash,

My problem having little difference ... We are passing SERIAL_NO from table PO_SERVICEACCESS_VALUES of BAPI_PO_GETDETAIL..If u see the SERIAL_NO of this table will always repeated numbers(like 01,02,01,02,03 etc...ofcourse this happens due to same G/L accounts and its corresponding WBS element)...but if u see the PO_ITEM_ACCOUNTASSIGNMENT table will give summarized SERIAL_NO of table PO_SERVICEACCESS_VALUES(this table dont have repeated SERIAL_NO)...we are passing the same table values to table ENTRYSHEETSRVACCASSVALUES(this table filled with values of PO_SERVICEACCESS_VALUES) and

ENTRYSHEETACCOUNTASSIGNMENT(this table filled with values

of PO_ITEM_ACCOUNTASSIGNMENT)...

even though we psssing above values correctly, we got more material documents while running bapi_entrysheet_Create...

please correct where i am wrong..

regards

dinesh.a

0 Kudos
92

Dinesh I think that might be the probelm don't pass the same value as you got from BAPI_PO_GETDETAIL.

Loop at PO_SERVICEACCESS_VALUES.

And pass the value like i have passed in ESLL structure.

Check u are passing PCKG_NO & LINE_NO from 1 to ...

For pckg_no u should pass the same value from PO.

bapi_esll-pckg_no = 1.

bapi_esll-line_no = line_no.

bapi_esll-outl_level = '0'.

bapi_esll-outl_ind = 'X'.

bapi_esll-subpckg_no = 2.

APPEND bapi_esll.

LOOP AT po_services WHERE NOT short_text IS INITIAL.

line_no = line_no + 1.

CLEAR bapi_esll.

  • MOVE-CORRESPONDING po_services TO bapi_esll.

  • bapi_esll-gr_price = '456'.

bapi_esll-pckg_no = 2.

bapi_esll-line_no = line_no.

bapi_esll-service = po_services-service.

bapi_esll-quantity = po_services-quantity.

bapi_esll-gr_price = po_services-gr_price.

bapi_esll-price_unit = po_services-price_unit.

APPEND bapi_esll.

ENDLOOP.

Hope it helpfull.

Regards,

Prakash.

0 Kudos
92

Ok,Prakash,

Thanks for your replies....Tomorrow i will try it out in office...if further thig needed i will let u know...

Regards

dinesh.a

0 Kudos
92

Good Dinesh.

Send me a mail if it works. prakash.ramu@wipro.com

Don't forget to reward

Regards,

Prakash.