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: 

BAPI Purchase Requisition create for ASSET

Former Member
0 Kudos

Hi expert ,

I want to create Purchase Requisition using BAPI_REQUISITION_CREATE ,

this is working fine for single PR create ,but for more than one items, asset numbers not updating correctly.

for eg- if item no 10 having asset no 106000000187 and

item no 20 having asset no 106000000188.

but in my program only last asset i.e.106000000188 is updated for both 10 and 20 item.

program code is as follow.

&----


*& Form FILL_BAPI

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_DATA.

LOOP AT IT_DATA.

*TRANSLATE IT_DATA-PR_VLTYP TO UPPER CASE.

T_REQUISITION_ITEMS-DOC_TYPE = IT_DATA-PR_TYPE.

T_REQUISITION_ITEMS-DELIV_DATE = IT_DATA-PR_DATE.

T_REQUISITION_ITEMS-PLANT = IT_DATA-PR_PLANT.

T_REQUISITION_ITEMS-PUR_GROUP = IT_DATA-PR_GROUP.

T_REQUISITION_ITEMS-ACCTASSCAT = IT_DATA-KNTTP.

T_REQUISITION_ITEMS-SHORT_TEXT = IT_DATA-TXZ01.

T_REQUISITION_ITEMS-QUANTITY = IT_DATA-PR_QTY.

T_REQUISITION_ITEMS-UNIT = IT_DATA-MEINS.

T_REQUISITION_ITEMS-C_AMT_BAPI = IT_DATA-price..

T_REQUISITION_ITEMS-MAT_GRP = IT_DATA-matkl. "'1001'.

APPEND T_REQUISITION_ITEMS.

REQUISITION_ACCOUNT_ASSIGNMENT-SERIAL_NO = IT_DATA-ZEBKN."1.

REQUISITION_ACCOUNT_ASSIGNMENT-ASSET_NO = IT_DATA-ANLN1. "'106000000187'.

APPEND REQUISITION_ACCOUNT_ASSIGNMENT.

ENDLOOP.

----


  • BAPI TO CREATE PR

----


CALL FUNCTION 'BAPI_REQUISITION_CREATE'

  • EXPORTING

  • SKIP_ITEMS_WITH_ERROR =

IMPORTING

NUMBER = E_NUMBER

TABLES

REQUISITION_ITEMS = T_REQUISITION_ITEMS

REQUISITION_ACCOUNT_ASSIGNMENT = REQUISITION_ACCOUNT_ASSIGNMENT"T_REQ_ACCOUNT_ASSIGNMENT

  • REQUISITION_ITEM_TEXT =

  • REQUISITION_LIMITS =

  • REQUISITION_CONTRACT_LIMITS =

  • REQUISITION_SERVICES =

  • REQUISITION_SRV_ACCASS_VALUES =

RETURN = T_RETURN

  • REQUISITION_SERVICES_TEXT =

  • EXTENSIONIN =

  • REQUISITION_ADDRDELIVERY =

.

IF NOT E_NUMBER IS INITIAL .

WRITE:/ 'REQ NO:' , E_NUMBER , 'CREATED'.

ELSE.

LOOP AT T_RETURN.

WRITE T_RETURN-MESSAGE.

ENDLOOP.

ENDIF.

ENDFORM. " FILL_BAPI

3 REPLIES 3

DirkAltmann
Active Participant
0 Kudos

Hi jyotsna,

you didn't populate the field PREQ_ITEM in both tables. But this is required, see also the BAPI documentation in the transaction "BAPI" for the Object "PurchaseRequisition" and the method "CreateFromData" and the parametername "RequisitionItems".

Regards

Dirk

0 Kudos

Hi,

I have also created a upload program using 'BAPI_REQUISITION_CREATE' . I have did the following things in my program

1) I took the BEDNR(Tracking No) field as the unique record for each PR document.

2)Then, i took two internal tables with the data from the file. One internal table i considered as header in which only the Number of PR Documents that is no item wise repeatability(Delete all adjacent duplicates in IT_head using BEDNR). In the Other internal table the data had as per the file that is item wise data also.

3)I looped the header IT_HEAD and inside that i looped IT_ITEM with a where condition BEDNR = IT_HEAD-BEDNR. So, the number of items will be populated successfully.

CALL FUNCTION 'BAPI_REQUISITION_CREATE'

EXPORTING

AUTOMATIC_SOURCE = 'X'

IMPORTING

number = gv_pr

TABLES

REQUISITION_ITEMS = it_item

REQUISITION_ACCOUNT_ASSIGNMENT = it_acct

REQUISITION_ITEM_TEXT = it_text

RETURN = it_ret

REQUISITION_ADDRDELIVERY = it_addr

.

refresh:it_item,it_acct,it_text,it_addr.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

4)for example if your PR is having 4 item like 10 ,20 ,30 & 40,then the internal table it_item and it_acct will have four entries.

Thanks & Regards,

Manesh.R

.

0 Kudos

This message was moderated.