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 for MIGO

Former Member
0 Kudos
12,078

HI,

Is there any BAPI for doing MIGO along with capturing excise values.

murali.c

13 REPLIES 13

Former Member
0 Kudos
1,744

Hi,

Try using the

"BAPI_GOODSMVT_CREATE"

Useful Links

Please close the thread, if solved

Regards,

Aditya

former_member206377
Active Contributor
0 Kudos
1,744

try this

BAPI_EXCINV_CREATE_FROMDATA BAPI

0 Kudos
1,744

Can you send sample code for the bapi

Former Member
0 Kudos
1,744

Hi,

Use, BAPI_GOODSMVT_CREATE

Thanks,

Krishna

0 Kudos
1,744

HI,

Thanks for quick reply...

I am able to successfully create the GR using BAPI_GOODSMVT_CREATE taking PO as the reference but unable to capture the excise values.

I am trying to use BAPI_EXCINV_CREATE_FROMDATA to capture excise values but without success.

pls guide me through this....

murali.c

0 Kudos
1,744

yes, you cannot use BAPI_GOODSMVT_CREATE for excise invoice.

what is the issue you are facing with BAPI_EXCINV_CREATE_FROMDATA ?

0 Kudos
1,744

Hi Vasuki,

I am here with giving you the code.... while calling BAPI_EXCINV_CREATE_FROMDATA..EVEN THOUGH IT IS NOT THROWING ANY ERROR ,it is not updating any excise values.

TABLES:zgate_data,zgate_data_p2.

*

  • BAPI TO Upload Inventory Data

*

  • GMCODE Table T158G - 01 - MB01 - Goods Receipts for Purchase Order

  • 02 - MB31 - Goods Receipts for Prod Order

  • 03 - MB1A - Goods Issue

  • 04 - MB1B - Transfer Posting

  • 05 - MB1C - Enter Other Goods Receipt

  • 06 - MB11

*

  • Domain: KZBEW - Movement Indicator

  • Goods movement w/o reference

  • B - Goods movement for purchase order

  • F - Goods movement for production order

  • L - Goods movement for delivery note

  • K - Goods movement for kanban requirement (WM - internal only)

  • O - Subsequent adjustment of "material-provided" consumption

  • W - Subsequent adjustment of proportion/product unit material

*

PARAMETERS: p_gentry LIKE zgate_data-zgentry OBLIGATORY.

DATA: BEGIN OF gmhead.

INCLUDE STRUCTURE bapi2017_gm_head_01.

DATA: END OF gmhead.

DATA: BEGIN OF gmcode.

INCLUDE STRUCTURE bapi2017_gm_code.

DATA: END OF gmcode.

DATA: BEGIN OF mthead.

INCLUDE STRUCTURE bapi2017_gm_head_ret.

DATA: END OF mthead.

DATA: BEGIN OF itab OCCURS 100.

INCLUDE STRUCTURE bapi2017_gm_item_create.

DATA: END OF itab.

DATA: BEGIN OF errmsg OCCURS 10.

INCLUDE STRUCTURE bapiret2.

DATA: END OF errmsg.

DATA: wmenge LIKE iseg-menge,

errflag.

DATA:BEGIN OF exhead.

INCLUDE STRUCTURE bapi_j_1iexchdr.

DATA:END OF exhead.

DATA:process_flag LIKE bapi_j_1iexchdr-ref_indicator.

DATA: BEGIN OF jtab OCCURS 100.

INCLUDE STRUCTURE bapi_j_1iexcdtl.

DATA: END OF jtab.

DATA:BEGIN OF pcitab OCCURS 0,

ebeln LIKE zgate_data-ebeln,

ebelp LIKE zgate_data-ebelp,

matnr LIKE zgate_data-matnr,

menge LIKE zgate_data-menge,

del_no LIKE zgate_data-zinvoice,

END OF pcitab.

DATA :t_bwart TYPE goitem-bwart.

DATA:z_mblnr TYPE mkpf-mblnr.

DATA: BEGIN OF it_mkpf OCCURS 0,

mblnr LIKE mkpf-mblnr,

bktxt LIKE mkpf-bktxt,

END OF it_mkpf.

DATA: zinvoice LIKE zgate_data-zinvoice.

DATA: zbukrs LIKE zgate_data-bukrs.

SELECT ebeln ebelp matnr menge FROM zgate_data INTO CORRESPONDING FIELDS OF TABLE pcitab WHERE zgentry = p_gentry.

SELECT SINGLE bukrs zinvoice FROM zgate_data INTO (zbukrs,zinvoice) WHERE zgentry = p_gentry.

*****************************************

SELECT mblnr bktxt INTO TABLE it_mkpf FROM mkpf WHERE bktxt = p_gentry.

SORT it_mkpf BY mblnr DESCENDING.

DELETE ADJACENT DUPLICATES FROM it_mkpf COMPARING bktxt.

LOOP AT it_mkpf.

MOVE it_mkpf-mblnr TO z_mblnr.

ENDLOOP.

SELECT SINGLE bwart FROM mseg INTO t_bwart WHERE mblnr = z_mblnr.

IF t_bwart = '101' .

MESSAGE 'GR already done against the Gate Entry No' TYPE 'E'.

ENDIF.

***************************************************************

gmhead-pstng_date = sy-datum.

gmhead-doc_date = sy-datum.

gmhead-pr_uname = sy-uname.

gmhead-ref_doc_no = zinvoice.

gmhead-header_txt = p_gentry.

gmcode-gm_code = '01'. "01 - MB01 - Goods Receipts for Purchase Order

LOOP AT pcitab.

itab-move_type = '101'. "pcitab-mvt_type.

itab-mvt_ind = 'B'.

  • itab-plant = pcitab-plant.

itab-material = pcitab-matnr.

itab-entry_qnt = pcitab-menge.

  • itab-move_stloc = pcitab-recv_loc.

itab-stge_loc = '3111'.

itab-po_number = pcitab-ebeln.

itab-po_item = pcitab-ebelp.

  • itab-item_text = zinvoice.

  • concatenate pcitab-del_no pcitab-del_item into itab-item_text.

  • itab-move_reas = pcitab-scrap_reason.

APPEND itab.

ENDLOOP.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

goodsmvt_header = gmhead

goodsmvt_code = gmcode

  • TESTRUN = ' '

IMPORTING

goodsmvt_headret = mthead

  • MATERIALDOCUMENT =

  • MATDOCUMENTYEAR =

TABLES

goodsmvt_item = itab

  • GOODSMVT_SERIALNUMBER =

return = errmsg

.

CLEAR errflag.

LOOP AT errmsg.

IF errmsg-type EQ 'E'.

WRITE:/'Error in function', errmsg-message.

errflag = 'X'.

ELSE.

WRITE:/ errmsg-message.

ENDIF.

ENDLOOP.

IF errflag IS INITIAL.

COMMIT WORK AND WAIT.

IF sy-subrc NE 0.

WRITE:/ 'Error in updating'.

EXIT.

ELSE.

WRITE:/ mthead-mat_doc, mthead-doc_year.

PERFORM upd_sta.

ENDIF.

ENDIF.

&----


*& Form upd_sta

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM upd_sta .

exhead-excise_number = zinvoice.

exhead-excise_date = sy-datum.

exhead-reference_doc = mthead-mat_doc.

exhead-ref_year = mthead-doc_year.

  • exhead-REF_INDICATOR = 'R'.

  • exhead-process_flag = 'I'.

DATA:v_chapid TYPE j_1ichid.

DATA:v_werks TYPE werks.

LOOP AT pcitab.

jtab-excise_invoice_date = sy-datum. "pcitab-mvt_type.

jtab-excise_year = mthead-doc_year.

jtab-excise_group = '31'.

  • jtab-DOCUMENT_ITEM =

SELECT SINGLE j_1ichid FROM j_1imtchid INTO v_chapid WHERE matnr = pcitab-matnr

AND werks = v_werks..

jtab-chapter_id = v_chapid.

jtab-material = pcitab-matnr.

jtab-challan_quantity = pcitab-menge.

jtab-storag_loc = '3111'.

jtab-reference_doc1 = pcitab-ebeln.

jtab-ref_item_1 = pcitab-ebelp.

jtab-ref_year_1 = mthead-doc_year.

jtab-ref_doc_2 = mthead-mat_doc.

jtab-ref_year_2 = mthead-doc_year.

  • jtab-REF_ITEM_2 =

APPEND jtab.

CLEAR v_chapid.

ENDLOOP.

CALL FUNCTION 'BAPI_EXCINV_CREATE_FROMDATA'

EXPORTING

obj_header = exhead

process_flag = 'I'

TABLES

obj_item = jtab

return = errmsg.

CLEAR errflag.

LOOP AT errmsg.

IF errmsg-type EQ 'E'.

WRITE:/'Error in function', errmsg-message.

errflag = 'X'.

ELSE.

WRITE:/ errmsg-message.

ENDIF.

ENDLOOP.

IF errflag IS INITIAL.

COMMIT WORK AND WAIT.

IF sy-subrc NE 0.

WRITE:/ 'Error in updating'.

EXIT.

ELSE.

WRITE:/ 'success'.

  • perform upd_sta.

ENDIF.

ENDIF.

.

.

ENDFORM. " upd_sta

Edited by: murali ch on Nov 25, 2009 10:01 AM

0 Kudos
1,744

Refer

0 Kudos
1,744

in such a case ,you will have to go for a BDC..

0 Kudos
1,744

HI,

I am using the following code with BAPI_EXCINV_CREATE_FROMDATA to capture excise values.eventhough it is not returning any error messages, neither it is updating excise values.

pls let me know whether my coding is correct or not?

  DATA:BEGIN OF exhead.
        INCLUDE STRUCTURE bapi_j_1iexchdr.
        DATA:END OF exhead.

DATA:process_flag LIKE bapi_j_1iexchdr-ref_indicator.

DATA: BEGIN OF jtab OCCURS 100.
        INCLUDE STRUCTURE bapi_j_1iexcdtl.
DATA: END OF jtab.


DATA: BEGIN OF errmsg OCCURS 10.
        INCLUDE STRUCTURE bapiret2.
DATA: END OF errmsg.

DATA: wmenge LIKE iseg-menge,
      errflag.
  DATA:v_chapid TYPE j_1ichid.

 exhead-excise_number = 'INV960/09'.
  exhead-excise_date = sy-datum.
  exhead-reference_doc = '5000001638'.
  exhead-ref_year = '2009'.
  exhead-REF_INDICATOR = 'R'.

    jtab-excise_invoice_date  = sy-datum.          "pcitab-mvt_type.
    jtab-excise_year    = '2009'.
    jtab-excise_group = '31'.
*    jtab-DOCUMENT_ITEM =

    SELECT SINGLE j_1ichid FROM j_1imtchid INTO v_chapid WHERE matnr =  '115'
                                                           AND werks = '3110'.

    jtab-chapter_id = v_chapid.
    jtab-material   = '115'.
    jtab-challan_quantity  = '1.000'.
    jtab-storag_loc   = '3111'.
    jtab-reference_doc1  = '4500000960'.
    jtab-ref_item_1    = '00010'.
    jtab-ref_year_1  = '2009'.
    jtab-ref_doc_2 = '5000001638'.
    jtab-ref_year_2 = '2009'.
    jtab-REF_ITEM_2 = '1'.
    APPEND jtab.

    CLEAR v_chapid.

CALL FUNCTION 'BAPI_EXCINV_CREATE_FROMDATA'
    EXPORTING
      obj_header   = exhead
      process_flag = 'I'
    TABLES
      obj_item     = jtab
      return       = errmsg.
  CLEAR errflag.
  LOOP AT errmsg.
    IF errmsg-type EQ 'E'.
      WRITE:/'Error in function', errmsg-message.
      errflag = 'X'.
    ELSE.
      WRITE:/ errmsg-message.
    ENDIF.
  ENDLOOP.

  IF errflag IS INITIAL.
    COMMIT WORK AND WAIT.
    IF sy-subrc NE 0.
      WRITE:/ 'Error in updating'.
      EXIT.
    ELSE.
      WRITE:/ 'success'.
   ENDIF.
  ENDIF. 

murali.c

0 Kudos
1,744

HI,

Answered .

After creating Material Document through MB01, I have used BDC for J1IEX for excise capturing.

thank u...

murali.c

Edited by: murali ch on Dec 8, 2009 12:16 PM

0 Kudos
1,744

Hi All,

Function BAPI_GOODSMVT_CREATE is not supported when i am creating Bapi for MIGO,

Its shows message " ID - M7 , Code is not supported by BAPI 2017_GOODSMVT_CREATE"

Please let me know how its can be resolved.

SE 37 ---> Function Module : BAPI_GOODSMVT_CREATE

Excecute : ID - M7 , Code is not supported by BAPI 2017_GOODSMVT_CREATE"

SAP Version : 4.7

0 Kudos
1,744

Hi All,

Function BAPI_GOODSMVT_CREATE is not supported when i am creating Bapi for MIGO,

Its shows message " ID - M7 , Code is not supported by BAPI 2017_GOODSMVT_CREATE"

Please let me know how its can be resolved.

SE 37 ---> Function Module : BAPI_GOODSMVT_CREATE

Excecute : ID - M7 , Code is not supported by BAPI 2017_GOODSMVT_CREATE"

SAP Version : 4.7