‎2008 Mar 21 7:53 PM
Hi
I am using BAPI_PO_CREAT1 for creation of PO
but i am getting these errors
PO could not be creating using the Enjoy-BAPI
Please enter material number or account assignment category
Purchase order still contains faulty items
kindly somone help me in solving this, and if possible provide me with code.
thanks
mannu
‎2008 Mar 21 8:54 PM
Hello Munish,
I see that there could be a problem with the flat file(Mat no in flat file format) or the source structure(Internal Table) that you have created according to the flat file structure.
However, I will provide you with a code that I had worked on 'BAPI_REQUISITION_CREATE' , I will alos provide you with a flat file. So that, It would be helpful for you to work with any other BAPI function mosules.
&----
*& Report ZBAPI_chaitu
*&
&----
*& AUthor : Krishna Chaitanya
*&
&----
REPORT ZBAPI_chaitu.
DATA: PRN LIKE BAPIEBANC-PREQ_NO.
DATA: ITEMBAPIEBANC LIKE BAPIEBANC OCCURS 0 WITH HEADER LINE.
DATA: RETURN1 LIKE BAPIRETURN OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF RECORD OCCURS 0,
STR(200),
END OF RECORD.
DATA: BEGIN OF HEAD,
DOC_TYPE(04),
END OF HEAD.
DATA: BEGIN OF ITEM,
DOC_TYPE(04),
MATERIAL(18),
QUANTITY(13),
PUR_GROUP(03),
PLANT(04),
DEL_DATCAT(1), " LIKE ITAB_BAPIEBANC-DEL_DATCAT,
DELIV_DATE(8)," LIKE ITAB_BAPIEBANC-DELIV_DATE,
END OF ITEM.
DATA: HEAD_COUNT TYPE I,
ITEM_COUNT TYPE I.
PERFORM UPLOAD.
loop at record.
IF RECORD+0(1) = 'H'.
IF HEAD_COUNT > 0.
PERFORM PROCESS_BAPI TABLES ITEMBAPIEBANC.
REFRESH ITEMBAPIEBANC.
ENDIF.
ITEM_COUNT = 0.
ADD 1 TO HEAD_COUNT.
HEAD = RECORD+1.
MOVE-CORRESPONDING HEAD TO ITEMBAPIEBANC.
ELSEIF RECORD+0(1) = 'I'.
ITEM_COUNT = 1.
ITEM = HEAD.
ITEM4 = RECORD1.
MOVE-CORRESPONDING ITEM TO ITEMBAPIEBANC.
APPEND ITEMBAPIEBANC.
CLEAR ITEMBAPIEBANC.
CLEAR ITEM.
ENDIF.
endloop.
sy-index = sy-index + 1.
if SY-INDEX <> 0.
PERFORM PROCESS_BAPI TABLES ITEMBAPIEBANC.
REFRESH ITEMBAPIEBANC.
ENDIF.
*enddo.
*CLOSE DATASET DATASET.
&----
*& Form UPLOAD
&----
text
----
--> p1 text
<-- p2 text
----
FORM UPLOAD.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILENAME = 'C:\WINDOWS\Desktop\CNU4.txt'
FILETYPE = 'ASC'
TABLES
DATA_TAB = RECORD.
ENDFORM. " UPLOAD
&----
*& Form PROCESS_BAPI
&----
text
----
--> p1 text
<-- p2 text
----
FORM PROCESS_BAPI TABLES i_item like ITEMBAPIEBANC[].
CALL FUNCTION 'BAPI_REQUISITION_CREATE'
EXPORTING
SKIP_ITEMS_WITH_ERROR =
IMPORTING
NUMBER = PRN
TABLES
REQUISITION_ITEMS = i_item
REQUISITION_ACCOUNT_ASSIGNMENT =
REQUISITION_ITEM_TEXT =
REQUISITION_LIMITS =
REQUISITION_CONTRACT_LIMITS =
REQUISITION_SERVICES =
REQUISITION_SRV_ACCASS_VALUES =
RETURN = RETURN1.
REQUISITION_SERVICES_TEXT =
if return1-type <> 'E'.
write:/ 'requisation created', PRN.
LOOP AT i_item.
MOVE-CORRESPONDING i_item to ITEM.
WRITE:/ ITEM.
CLEAR ITEM.
ENDLOOP.
ELSE.
WRITE:/ RETURN1-MESSAGE.
LOOP AT i_item.
MOVE-CORRESPONDING i_item to ITEM.
WRITE:/ ITEM.
CLEAR ITEM.
ENDLOOP.
endif.
ENDFORM. " PROCESS_BAPI
**********************************************************
**********************************************************
***********************************************************
Flat file for 'BAPI_REQUISITION_CREATE'
**********************************************************
***********************************************************
HNB
IMAT700-700 200 0010001120040111
IMAT700-700 300 0010001120040205
IMAT700-700 400 0010001120040110
IMAT700-700 500 0010001120040108
HNB
IMAT700-700 200 0010001120040111
IMAT700-700 300 0010001120040211
IMAT700-700 400 0010001120040311
IMAT700-700 500 0010001120040411
************************************************************
This would be helpful information for you Munish!
All the Best!
Regards
Krishna Chaitanya
‎2008 Mar 21 8:56 PM
Hello Munish,
Go through this code, I had worked on BAPI_PO_CREATE1 too.....I will try to get the code for you from my workplace...Mean while...Try to Analyze the things from the above code..
Do not forget to mark the reward points,
All the best!
Regards,
Krishna Chaitanya
Edited by: Krishna Chaitanya on Mar 21, 2008 9:57 PM