BAPI for goods moment is not working in loop

Dear ABAPers,
If i am using BAPI ( for MB1n transabtion for goods movement type 309 )with in loop first one is working fine and remaining is not working.
If i run individually all r working fine.
I am sending cdoe as below.
Pl hava look on that.
  LOOP AT ITAB.
    CLEAR: GM_RETURN, GM_RETMTD,GM_HEADER,GM_CODE,GM_HEADRET.
    REFRESH: GM_RETURN,GM_ITEM.
    GM_HEADER-PSTNG_DATE = SY-DATUM.
    GM_HEADER-DOC_DATE   = SY-DATUM.
    GM_CODE-GM_CODE      = '04'.                            " MB1B
    CLEAR GM_ITEM.
    MOVE '309'                 TO GM_ITEM-MOVE_TYPE     .
    MOVE ITAB-MATNR  TO GM_ITEM-MATERIAL.
    MOVE ITAB-MENGE_REC TO GM_ITEM-ENTRY_QNT.
    MOVE ITAB-MATNR_REC TO GM_ITEM-MOVE_MAT.
    MOVE ITAB-MEINS_REC TO GM_ITEM-BASE_UOM.
    MOVE ITAB-WERKS_REC  TO GM_ITEM-PLANT.
    MOVE ITAB-LGORT_REC  TO GM_ITEM-STGE_LOC.
    MOVE ITAB-CHARG TO GM_ITEM-BATCH.
    MOVE ITAB-CHARG_REC TO GM_ITEM-MOVE_BATCH.
    APPEND GM_ITEM.
    CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
      EXPORTING
        GOODSMVT_HEADER  = GM_HEADER
        GOODSMVT_CODE    = GM_CODE
      IMPORTING
        GOODSMVT_HEADRET = GM_HEADRET
        MATERIALDOCUMENT = GM_RETMTD
      TABLES
        GOODSMVT_ITEM    = GM_ITEM
        RETURN           = GM_RETURN.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
  WAIT          =
IMPORTING
  RETURN        =
    IF GM_RETURN[] IS NOT INITIAL.
      LOOP AT GM_RETURN.
        IF GM_RETURN-TYPE = 'E'.
          ERR_CNT = ERR_CNT + 1.
          V_MESSAGE = GM_RETURN-MESSAGE.
          UPDATE Y_MB1B SET STS_CODE = 'PE'
                           UPDATE_BY = SY-UNAME
                           UPDATE_DATE = SY-DATUM
                           MESS = V_MESSAGE
               WHERE SRL = ITAB-SRL.
        ENDIF.
      ENDLOOP.
    ELSE.
      IF GM_RETMTD IS NOT INITIAL.
        REC_CNT = REC_CNT + 1.
        CONCATENATE 'Document' GM_RETMTD 'posted' INTO V_MESSAGE SEPARATED BY SPACE.
        UPDATE Y_MB1B SET STS_CODE = 'PS'
                   UPDATE_BY = SY-UNAME
                   UPDATE_DATE = SY-DATUM
                   MESS = V_MESSAGE
       WHERE SRL = ITAB-SRL.
      ENDIF.
    ENDIF.
  ENDLOOP.
Pl gimme solution.
Cheers,
Simha.

Hi,
               here is the code check this for ur ref
method IF_EX_LE_SHP_GOODSMOVEMENT~CHANGE_INPUT_HEADER_AND_ITEMS .
******** Data Declaration *************
  data: ls_lips type lips.
  data: ls_goods_header type BAPI2017_GM_HEAD_01.
  data: ls_gm_code type BAPI2017_GM_CODE.
  data: ls_goods_mvt type BAPI2017_GM_ITEM_CREATE.
  data: lt_goods_mvt type table of BAPI2017_GM_ITEM_CREATE.
  data: lt_return type table of BAPIRET2.
  data:ls_MATERIALDOCUMENT type BAPI2017_GM_HEAD_02-MAT_DOC.
  data: ls_MATDOCUMENTYEAR type BAPI2017_GM_HEAD_02-DOC_YEAR.
  constants: c_bwart type lips-bwart value '309'.
  ls_goods_header-PSTNG_DATE = sy-datum.
  ls_goods_header-DOC_DATE   = IS_LIKP-bldat.
  ls_goods_header-pr_uname = sy-uname.
  ls_gm_code-GM_CODE         = '06'.
  loop at it_xlips into ls_lips
       where OIC_MOT = 'PK'.
    if ( ls_lips-uepos is initial and ls_lips-pstyv = 'TAQ').
      ls_goods_mvt-MATERIAL = ls_lips-MATNR.
      ls_goods_mvt-PLANT = ls_lips-WERKS.
      ls_goods_mvt-STGE_LOC = ls_lips-LGORT.
      ls_goods_mvt-MOVE_TYPE = c_bwart.
      ls_goods_mvt-ENTRY_QNT = ls_lips-LFIMG.
      ls_goods_mvt-MOVE_MAT = ls_lips-UMMAT.
      ls_goods_mvt-MOVE_PLANT = ls_lips-UMWRK.
      ls_goods_mvt-MOVE_STLOC = ls_lips-UMLGO.
      append ls_goods_mvt to lt_goods_mvt.
    endif.
  endloop.
by this call function BAPI Material document is created ****
  data : LS_GOODSMVT_HEADRET     TYPE BAPI2017_GM_HEAD_RET.
  CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
    EXPORTING
      GOODSMVT_HEADER  = ls_goods_header
      GOODSMVT_CODE    = ls_gm_code
    IMPORTING
      GOODSMVT_HEADRET = LS_GOODSMVT_HEADRET
    TABLES
      GOODSMVT_ITEM    = lt_goods_mvt
      RETURN           = lt_return.
  IF lt_return[] is NOT initial.
<b>Reward points</b>
Regards

Similar Messages

  • Link for territory mgmt is not working

    Hi All,
    We have territory management configured for three custom attributes.
    Link for territory management is not working for territory assignment block on account overview screen.
    Any hint how we can solve this issue?
    Thanks and Regards,
    Gauri.

    How are you resetting the password?
    Resetting User Password in Lion, Mountain Lion & Mavericks
    Boot into your Recovery Partition by hold down the Command and R keys whilst booting.
    When the Recovery screen appears, go to the Utilities menu and open Terminal.
    In Terminal, type:
    resetpassword
    ...a small app will open and allow you to choose the user for whom you want to change the password. If you are the admin, be certain that you choose your admin user. Type in your new password twice and give yourself a good hint. Click OK (or Done or whatever) and reboot, enjoying the use of your new, hopefully memorable, password.
    Good luck,
    Clinton

  • BAPI for Goods Movment Creation

    Hi
        I created Goods Movment with bapi BAPI_GOODSMVT_CREATE. for MIGO transaction
        After that i need to change vendor at detaild data level in under Freight (MIGO transaction).
    or else is it posible to pass our own vendor to that particlar level at time of creation using BAPI_GOODSMVT_CREATE
    Regards,
    Hari

    Did you come to [Note 520813 - FAQ: BAPIs for goods movements|https://service.sap.com/sap/support/notes/520813] ?
    Regards,
    Raymond

  • BAPI for Goods Issue (MIGO) movement type 351 with reference to PO

    Hi,
    Is there an BAPI for Goods issue in MIGO with reference to PO movement type 351, i tried using "BAPI_GOODSMVT_CREATE", but there is no PO field in this, is there any other BAPI's available for the same?
    Thanks in Advance,
    Santosh

    for goods mvt type , the available is that itself . for 351 mvt type Po number is not required .
    if its a must , create a Z bapi with additional field  for PO and make it as reference .

  • BAPI for goods reciept posting

    Hi,
         Can Any one provide me BAPI for goods reciept posting.
    Thanks.
    Moderator message: please try finding out yourself before asking.
    locked by: Thomas Zloch on Aug 17, 2010 10:55 AM

    HI,
         Have a look at
    BAPI_GOODSMVT_CREATE
    BAPI_ACC_GOODS_MOVEMENT_CHECK
    BAPI_ACC_GOODS_MOVEMENT_POST
    Regards,
    S.Velsankar
    Moderator message: please do not encourage laziness by replying to such questions!
    Edited by: Thomas Zloch on Aug 17, 2010 11:00 AM

  • What can I do for the following situation: I think my insert slot for the headphones does not work; when I put in any cable that should and can go in all I hear is low frequent static sounds.

    What can I do for the following situation: I think my insert slot for the headphones does not work; when I put in any cable that should and can go in all I hear is low frequent static sounds.

    You might try talking to the Apple store manager and see if you don't get more help...you might also contact Apple.com/support and see if they can give you a contact with the Apple Italy offices.
    Sounds like you have two levels of failure, the first shop that did the repair and broke a wire, and the second that has disabled something else and isn't helping.
    Apple officially refurbished equipment is usually good quality.  Surprising this has happened but you need to press on with complaints and try for resolution.

  • HT1947 Remote for ipad landscape orientation not working in ios 7

    Remote for ipad landscape orientation not working in ios 7

    See this thread: remote app rotation locked in portrait orientation after iOS 7 upgrade
    It is a discussion only - no helpful hints.  Appears to be a bug for sure.

  • My dvd slot for imac10,1 does not work. It rejects the disc. Problem after reinstall of backup from hdd.

    My dvd slot for imac10,1 does not work. I had a new harddrive installed in November and the MacStore installed my backups from an external harddrive. I do not use it other than to upload programs, so I have not tried using it until tax season, but it rejects the disc. The ata file indicates no dvd firmware, but the serial-ata does indicate firmware for a dvdrw. What might I do about this to bring the dvd back, least expensive to most?

    Yesterday I started having the same problem. Can read disc (play movies and music) but blank disk are ejected or idvd cannot see the blank disk. I have a almost 12 month old 27" i7 imac.

  • I want to reset my ipod touch 4th gen but i have forgotten the restrictions passcode and for some reason its not working on my laptop on itunes and the restore thing wont work! any help?

    I want to reset my ipod touch 4th gen but i have forgotten the restrictions passcode and for some reason its not working on my laptop on itunes and the restore thing wont work! any help?

    Make sure you have the Current Version of iTunes Installed on your computer
    iTunes free download from www.itunes.com/download
    Then See Here  >  http://support.apple.com/kb/HT1808
    You may need to try this More than Once...  Be sure to Follow ALL the Steps...
    Take your time... Pay particular attention to Steps 3 and 4.
    After you have Recovered your Device...Re-Sync your Content
    Note:
    To remove a forgotten Restrictions passcode you will need to  Restore the Device as New...
    OR... From a Backup created Before the Restrictions Code was set....

  • Auto To working for one material and not working for other material

    Hi,
    Hope everybody is doing fine.
    I have configured the auto TO. Its working fine for one material and not working for the other material. I checked the material master and wm 1,2 views have the same fileds / values. What could be wrong?
    I didn't setup the back ground processing job. Is that is affecting it?
    thanks for any help.
    regrads,
    KHAN

    Thnaks,
    You are right but then what could be wrong? Its working for one material and not working for otehr material? Any clue?
    Appreciate your time charlie

  • My new Dell PC running Windows 8 does not recognize my iPad or iPhone. Worked OK for iPhone for months but would not work for new iPad.  I removed /relaoded iTunes and now it won't recognize either iPad or iPhone.

    My new Dell PC running Windows 8 does not recognize my iPad or iPhone. Worked OK for iPhone for months but would not work for new iPad.  I removed /relaoded iTunes and now it won't recognize either iPad or iPhone. Got any suggestions?

    Hi there Lizabethfromaz,
    You may find the troubleshooting steps in the article below helpful.
    iOS: Device not recognized in iTunes for Windows
    http://support.apple.com/kb/ts1538
    -Griff W. 

  • Can't get to settings to turn on wifi because "sign in to icloud" pops up and asks for pw which does not work because i can't get to wifi  ?p

    can't get to settings to turn on wifi because "sign in to icloud" pops up and asks for pw which does not work because i can't get to wifi  ?

    The problem is I cannot turn on wireless setting.  The "sign in to icloud  -- enter appleid password" popup will not go away. when i enter the pw and click ok, the same balloon pops up again.  If I click "cancel" it pops again. Since I am not on the internet (because I cannot turn the ipad wireless on) the sign in to icloud obviously will not work.  Vicious circle.

  • Valuation Basis for Different Payment (BWGRL) not working in 2010

    Hi
    We have a commission wagetype which we entered in IT 2010 in Number/Unit field. 
    Since we don't have premium id available, we used "Valuation Basis for Different Payment (BWGRL)"  to enter the RATE.
    This RATE is not working during our payroll run, however when we are using the wagetype with premium ID it is working fine.
    My question is- What could be the reason that the Valuation Basis for different payment is not working ? 
    I checked the wagetype in V_512W_B table and it has the following configuration-
    Current wage type
    Valuation Basis = BLANK
    Statement/WT = BLANK
    %Rate = 100
    1st derived wage type
    Valuation Basis = BLANK
    Statement/WT = BLANK
    %Rate = BLANK
    2nd derived wage type
    Valuation Basis = BLANK
    Statement/WT = BLANK
    %Rate = BLANK
    Would appreciate if the the fix could be provided.
    Saurabh Garg

    Hello,
    I think in your case for commision wagetype you need to modify rule $930 to process the override rate from Infotype 2010 BWGRL field in case you are using the US standard schema.
    The valuation basis table V_512W_D and rule $930 together will determine the valuation basis.
    The default valuation basis comes from table V_512W_D.In case you want to override the valuation basis rate defined in this table,you need to maintain override rate in It2010 and accordingly have the logic defined in rule $930 for that particular wagetype .
    Following is the sample rule definition for a similar scenario.
    ****(commision wagetype)
      NUM= ANZHL Set
      RTE= BWGRL Set
      RTE?0      Comparison
          MULTI NRA  Multipl.amt/no/rate
          SETIN X=NX Set variable split
          ADDWT *    OT   Output table
        =
          VALBS0     Eval.0.WT in 512W
          MULTI NRA  Multipl.amt/no/rate
          SETIN X=NX Set variable split
          ADDWT *    OT   Output table
    Regards,
    Malathi V.

  • New Hunt Pilot for internal number is not working.

    Hi support, I have a problem with the new hunt pilot number that created for internal use is not working. I had create 1 internal number (1090) for the Hunt Pilot number, and there are 2 hunt group member (9382 / 9387). These number will forward all to the mobile number 9382 will forward
    all to 90176253579 9387 will forward all to 90133921295 Calling from 1941 to 1090 resulted failed but calling from 1941 to 9382 working and the call forwarded to mobile 90176253579. What might be wrong with the 1090 where i can't call that number from internal. From the DNA, it shows the call should reachable to the destination. I attached the DNA result for your reference.

    Hi Mohd Afadzal,
    Forwarding setting do no apply for Line Group members. As you mentioned that the Line group members
    (9382 / 9387) are configured to forward all calls to their respective cell phones, this will not work.
    You can use the HuntPilot's Busy or No Answer configuration to forward calls to an alternate number.
    HTH,
    Jagpreet Singh Barmi

  • Can we get reimbursed for apps that do not work

    Can I get reimbursed for apps that do not work?

    Hi...
    You can contact iTunes support here and see if they will make an exception:
    http://www.apple.com/support/itunes/contact/
    They usually respond within 24 hours.
    Hope this helps.

Maybe you are looking for

  • Max IPs in a DHCP range for Roaming network?

    Setting up an AirPort roaming network comprised of a dozen or so AirPort-Extremes all connected via a Fast Ethernet backbone. The Master base station has a Public IP on it's WAN side and is Set to 'Share a Public IP address' and DHCP - but it seems n

  • Flash Markers and the SDK

    Hi All, I have no experience with the SDK but I am a competent programmer so could probably pick it up but I wanted to ask whether anyone knows if you can access markers on the timeline through the SDK and move them hopefully. My idea is to write a p

  • Iphoto editing in external photo editor

    How do I get a new photo editing application to appear in the "edit photo" dialog box within advanced preferences? A newly installed photoshop version is not an option to select within the box, only an older version.

  • HT204389 Whenever I wanna use Siri, it says : sorry, I can't take any request right now please try again in a while. What can I do?

    Whenever I wanna use Siri, it says : sorry, I can't take any request right now please try again in a while. What can I do?

  • XP Boot over Firewire?

    I have a mac mini and i would like to install windows XP on it, but i only have a 80gb hard drive. I have lots of drives floating around my office and i have a Seagate 320gb Sata drive i would like to put in a firewire enclosure. Using Firewire can i