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

Error: Enter a sales order for special stock E

former_member209770
Participant
0 Kudos
4,292

Dear Gurus,

I have a requirement  to post stock from unrestricted to QI (using mvtype 322).

I have already give the SO & SOItem, but I can't figure out why it still show the error msg : Enter a sales order for special stock E.

Can you please tell me why? Thanks very much in advance...

-------------------------------------------------------------------

tables: mchb, mard, mska, lips. 

parameters: p_matnr like mchb-matnr,

                  p_werks like mchb-werks,

                  p_charg like mchb-charg,

                  p_lgort like mard-lgort,

                  p_vbeln like LIPS-KDAUF,    "SO

                  p_posnr like LIPS-KDPOS.   "SOItem

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: v_labst like mard-labst.  

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

start-of-selection.

itab-material = p_matnr.

itab-plant = p_werks.

itab-batch = p_charg.

itab-stge_loc = p_lgort.

ITAB-MOVE_STLOC = p_lgort.

itab-MOVE_BATCH = p_charg.

select single KALAB from mska  into v_labst

       where matnr = p_matnr  

       and   werks = p_werks 

       and   lgort = p_lgort 

       and   CHARG = p_charg  

       AND   SOBKZ = 'E'      

       AND   VBELN = p_vbeln

       AND   POSNR = p_posnr.

gmhead-pstng_date = sy-datum.

gmhead-doc_date = sy-datum.

gmhead-pr_uname = sy-uname.

gmcode-gm_code = '04'.

itab-move_type = '322'. 

itab-entry_qnt  = v_labst.

itab-SPEC_STOCK = 'E'.

ITAB-SALES_ORD = p_vbeln.

ITAB-S_ORD_ITEM = p_posnr.

    append itab.

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.

  endif.

endif.

6 REPLIES 6

Former Member
0 Kudos
1,479

Have you discussed with your PP or procurement or WM/IM specialists and SD specialists on why this movement, etc., requires a sales order?  Appears that config expects that the material and quantity reference a sales order?

0 Kudos
1,479

Yes, because our company is BTO (Build to order), so there must be some quantity reference sales order.

But if i try the same situation with MB1B it is fine.

Can u tell me why? THX~

0 Kudos
1,479

hi,,,

Error. Enter a sales order for special stock E ,

when i do transfer posting  for materials another st.loction  (using mvt type :311 )

by : N.M sairajkumar

Former Member
0 Kudos
1,479

Hi,

You should use "val_sales_ord" and "val_s_ord_item" parameters of item table.

ITAB-VAL_SALES_ORD = p_vbeln.

ITAB-VAL_S_ORD_ITEM = p_posnr.


instead of

ITAB-SALES_ORD = p_vbeln.

ITAB-S_ORD_ITEM = p_posnr.

VenkatRamesh_V
Active Contributor
0 Kudos
1,479

Hi,

Try,

Passing the sale order and item to the following fields.

        wa_item-sales_ord                  =  wa_dis-kdauf.

         wa_item-s_ord_item               =  wa_dis-kdpos.

         wa_item-VAL_SALES_ORD     =  wa_dis-kdauf.

         wa_item-VAL_S_ORD_ITEM    =  wa_dis-kdpos.

Hope it helpful,

Regards,

Venkat.

0 Kudos
1,243

This is working Fine,
Thanks for Sharing.