04-19-2014 4:07 AM
i have created a bapi to upload data for MIGO transaction.. (GOODS RECEIPT-->PURCHASE ORDER)
i am getting the error " stock posting is not possible for this material "'.
when i create directly, it is posted.. while uploading through the program it shows the above error.
please suggest if anyone knows....
Thanks in advance,
Dhivya N.
04-19-2014 4:24 AM
Hello Dhivya.
You have made use of BAPI_GOODSMVT_CREATE?
Please paste your code snippet for better analysis.
Regards.
04-19-2014 4:26 AM
*&---------------------------------------------------------------------*
*& Report ZR_MIGO_UPLOAD
*& package name : zabap
*&---------------------------------------------------------------------*
*& transport request number : MIDK901443
*& program to upload goods movement
*&---------------------------------------------------------------------*
REPORT ZR_MIGO_UPLOAD.
***DATA DECLARATION***
type-POOLs: icon.
TYPES: BEGIN OF TY_GR_PO,
EBELN(10) TYPE c , "'PO NUMBEr
EBELP(10) TYPE c, "PO ITEM NUMBER
* LGOBE TYPE LGOBE, "STORAGE LOCATION DESCRIPTION
LGORT(10) TYPE c, "STORAGE LOCATION
XFELD TYPE c, "ITEM OK
GERNR(10) TYPE c, "SERIALNUMBER
END OF TY_GR_PO.
DATA: TA_GR_PO TYPE TABLE OF TY_GR_PO, "TABLE FOR GOODS RECEIPT PURCHASE ORDER
WA_GR_PO TYPE TY_GR_PO.
DATA: BLDAT TYPE BLDAT, "DOCUMENT DATE
BUDAT TYPE BUDAT, "POSTING DATE
WEVER TYPE WEVER. "VERSION FOR PRINTING GR SLIP
***BAPI DECLARATION***
DATA: BEGIN OF GM_HEAD OCCURS 0. "Material Document Header Data
INCLUDE STRUCTURE BAPI2017_GM_HEAD_01.
DATA: END OF GM_HEAD.
DATA: BEGIN OF GM_CODE OCCURS 0.
INCLUDE STRUCTURE BAPI2017_GM_CODE. "Assign Code to Transaction for Goods Movement
DATA: END OF GM_CODE.
DATA: BEGIN OF GM_RET OCCURS 0.
INCLUDE STRUCTURE BAPI2017_GM_HEAD_RET. "Material Document Number/Material Document Year
DATA: END OF GM_RET.
DATA: BEGIN OF GM_ITEM OCCURS 0.
INCLUDE STRUCTURE BAPI2017_GM_ITEM_CREATE. "Material Document Items
DATA: END OF GM_ITEM.
DATA: BEGIN OF GM_SER OCCURS 0.
INCLUDE STRUCTURE BAPI2017_GM_SERIALNUMBER. "Serial Number
DATA: END OF GM_SER.
data: BEGIN OF ta_bapireturn OCCURS 0.
INCLUDE STRUCTURE BAPIRET2.
data: END OF ta_bapireturn.
***declaration of excel file handling table***
FIELD-SYMBOLS: <fs> type any. "field symbol for alsm_excel
DATA: TA_EXCEL TYPE TABLE OF ALSMEX_TABLINE, "table to contain excel sheet values
WA_EXCEL TYPE ALSMEX_TABLINE.
***declaration of other parameters***
data: V_brow type i VALUE 2, "BEGIN OF ROW
V_bcol type i value 1, "BEGIN OF COL
V_erow type i value 65536, "END OF ROW
V_ecol type i value 256. "END OF COLUMN
DATA: V_sear type string,
V_INDEX TYPE i,
V_tabix type sy-tabix, "current line.
v_lines type i. "total number of records
DATA: DATE TYPE DATS.
**********************************************************************
***SELECTION SCREEN***
**********************************************************************
***SELECTION SCREEN DESIGN***
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP 3.
PARAMETERS: zCODE(2) TYPE C MATCHCODE OBJECT H_T158G,
zrefdoc type REFDOC,
version type WEVER.
SELECTION-SCREEN skip 5.
PARAMETERS: p_file type ibipparms-path.
SELECTION-SCREEN SKIP 3.
SELECTION-SCREEN END OF BLOCK b1.
***SELECTION SCREEN VALUE REQUEST***
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME' "f4 help for file name
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = P_FILE.
***SELECTION SCREEN EVENT***
AT SELECTION-SCREEN. "validation
if p_file <> ''.
V_sear = p_file.
SEARCH V_sear for '.xls'.
if sy-subrc <> 0.
message 'please provide excel file. it is not valid' type 'E'.
ENDIF.
ENDIF.
INITIALIZATION.
* DATE = '17.04.14'.
GM_HEAD-PSTNG_DATE = SY-DATUM.
GM_HEAD-DOC_DATE = SY-DATUM.
gm_head-pr_uname = sy-uname.
**********************************************************************
***START OF SELECTION***
**********************************************************************
START-OF-SELECTION.
gm_head-REF_DOC_NO = zrefdoc.
gm_head-VER_GR_GI_SLIP = version.
GM_CODE-GM_CODE = zCODE.
PERFORM EXCEL_UPLOAD.
PERFORM EXCEL_CONVERSION.
PERFORM NO_RECORDS.
END-OF-SELECTION.
PERFORM BAPI_ASSIGNMENT.
PERFORM BAPI_FM.
*&---------------------------------------------------------------------*
*& Form EXCEL_UPLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM EXCEL_UPLOAD .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = V_BCOL
I_BEGIN_ROW = V_BROW
I_END_COL = V_ECOL
I_END_ROW = V_EROW
TABLES
INTERN = TA_EXCEL
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
ENDFORM. " EXCEL_UPLOAD
*&---------------------------------------------------------------------*
*& Form EXCEL_CONVERSION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM EXCEL_CONVERSION .
if ta_excel is NOT INITIAL.
sort ta_excel by row col.
clear wa_excel.
clear wa_GR_PO.
LOOP AT ta_excel INTO wa_excel.
move wa_excel-col to v_index.
ASSIGN COMPONENT v_index OF STRUCTURE wa_GR_PO to <fs>.
if sy-subrc = 0.
move wa_excel-value to <fs>.
ENDIF.
at END OF row.
append wa_GR_PO to ta_GR_PO.
clear wa_GR_PO.
ENDAT.
ENDLOOP.
else.
MESSAGE 'no data for conversion' type 'I'.
ENDIF.
ENDFORM. " EXCEL_CONVERSION
*&---------------------------------------------------------------------*
*& Form NO_RECORDS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM NO_RECORDS .
DESCRIBE TABLE ta_GR_PO LINES v_lines.
if v_lines = 0.
MESSAGE 'NO RECORDS TO UPLOAD' TYPE 'E'.
ENDIF.
ENDFORM. " NO_RECORDS
*&---------------------------------------------------------------------*
*& Form BAPI_ASSIGNMENT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BAPI_ASSIGNMENT .
IF TA_GR_PO IS NOT INITIAL.
LOOP AT TA_GR_PO INTO WA_GR_PO.
gm_item-PO_NUMBER = wa_gr_po-ebeln.
GM_ITEM-STGE_LOC = WA_GR_PO-LGORT.
GM_ITEM-PO_ITEM = WA_GR_PO-EBELP.
GM_ITEM-NO_MORE_GR = 'X'."WA_GR_PO-XFELD'.
* GM_SER-SERIALNO = WA_GR_PO-GERNR.
gm_item-NO_MORE_GR = 1.
gm_item-ENTRY_QNT = 2.
gm_item-MOVE_TYPE = 101.
* gm_item-MVT_IND = 'B'.
gm_item-plant = 'P001'.
gm_item-move_stloc = 'FG01'.
* GM_ITEM-SPEC_STOCK = 'K'.
APPEND GM_ITEM.
APPEND GM_SER.
ENDLOOP.
ELSE.
MESSAGE 'DATA IS NOT UPLOADED' TYPE 'I'.
ENDIF.
ENDFORM. " BAPI_ASSIGNMENT
*&---------------------------------------------------------------------*
*& Form BAPI_FM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BAPI_FM .
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
GOODSMVT_HEADER = gm_head
GOODSMVT_CODE = gm_code
* TESTRUN = ' '
* GOODSMVT_REF_EWM =
IMPORTING
GOODSMVT_HEADRET = gm_ret
* MATERIALDOCUMENT =
* MATDOCUMENTYEAR =
TABLES
GOODSMVT_ITEM = gm_item
GOODSMVT_SERIALNUMBER = gm_ser
RETURN = ta_bapireturn
* GOODSMVT_SERV_PART_DATA =
* EXTENSIONIN =
.
if ta_bapireturn-type = 'S'.
write:/ icon_green_light as icon,
'success: Material document',gm_ret-mat_doc, 'is created for the GOODS RECEIPT- po number : ', wa_gr_po-ebeln,
/ 'reason:' , ta_bapireturn-message.
ELSEIF ta_bapireturn-type = 'E'.
write:/ icon_red_light as icon,
'error: Material document',gm_ret-mat_doc , 'is not created for the GOOD RECEIPT- po number : ', wa_gr_po-ebeln,
/ 'reason:' , ta_bapireturn-message.
ENDIF.
ENDFORM. " BAPI_FM
04-19-2014 4:37 AM
04-19-2014 4:59 AM
hai arun,
i have passed those things. still, i am getting the error
no goods receipt is possible for the <purchase order number> and <item>
04-19-2014 5:18 AM
Dhivya,
Did you pass gm_item-ENTRY_UOM value?
Have you passed GM_CODE value as 1?
04-19-2014 5:39 AM
04-19-2014 5:50 AM
Dhivya,
Always declare with reference to standard table-fields.
TYPES: BEGIN OF TY_GR_PO,
EBELN(10) TYPE c , "'PO NUMBEr
EBELP(10) TYPE c, "PO ITEM NUMBER
* LGOBE TYPE LGOBE, "STORAGE LOCATION DESCRIPTION
LGORT(10) TYPE c, "STORAGE LOCATION
XFELD TYPE c, "ITEM OK
GERNR(10) TYPE c, "SERIALNUMBER
END OF TY_GR_PO.
Declare like:
EBELN like EKPO-ebeln,
EBELP like EKPO-ebelp,
LGORT like EKPO-lgort,
GERNR type GERNR.
By declaring so, automatically internal conversions (like preceding zeroes) will take place.
04-19-2014 6:21 AM
Balaji is right. Once BAPI return 'S' , you have to use BAPI_TRANSACTION_COMMIT to realize the GR.
Before that, you need to pass all the relevant data correctly to eliminate the errors from BAPI_GOODSMVT_CREATE.
04-19-2014 4:46 AM
Hi,
Please Use this Bapi for creation of MIGO
Create Material document through Bapi BAPI_GOODSMVT_CREATE
then update part1 in J1I5, then post part2 in J1IEX
Thanking you
Mahesh
04-19-2014 5:01 AM
04-19-2014 5:59 AM
Hi divya,
As per my knowledge without calling BAPI_TRANSACTION_COMMIT the data is not uploaded in data base.
ex:when bapiret2 = 's'.
call BAPI_TRANSACTION_COMMIT.