ABAP code to get MM Movement Types into BI

Hi All,
I need help in ABAP code to extract data on MM tables for Purchase Price Variance Raw Material. I'm getting material documents for all reversals 102 movement type and not extracting followed up 544 or 543 values for same documents. I don't have much idea about ABAP in depth.
program using BSIS, BKPF , EKBE, MSEG, MKPF, EKPO tables to extract data.
See below pieces of code from program.
DATA: TEMP_AWKEY LIKE BKPF-AWKEY,
      YEAR(4) TYPE N,
      WRX_AMT TYPE BSEG-DMBTR,
      PRD_AMT TYPE BSEG-DMBTR,
      WP_AMT TYPE BSEG-DMBTR,
      QTY TYPE BSEG-MENGE,
      I_BSIS_WA TYPE I_BSIS_TYPE,
      MATDOC TYPE MSEG-MBLNR,
      MATDOC_YEAR TYPE MSEG-MJAHR,
      PERIOD(2) TYPE N.
DATA:
            ITAB_MSEG TYPE HASHED TABLE OF ITAB_MSEG_TYPE WITH UNIQUE KEY MBLNR MJAHR ZEILE WITH HEADER LINE INITIAL SIZE 0,
      ITAB_MSEG2 TYPE HASHED TABLE OF ITAB_MSEG_TYPE WITH UNIQUE KEY MBLNR MJAHR ZEILE WITH HEADER LINE INITIAL SIZE 0,
READ TABLE ITAB_BSEG WITH TABLE KEY BUKRS = I_BSIS-BUKRS BELNR = I_BSIS-BELNR GJAHR = I_BSIS-GJAHR BUZEI = I_BSIS-BUZEI  .
      IF SY-SUBRC EQ 0.
        MOVE :
           ITAB_BSEG-MEINS TO I_BSIS-MEINS,
           ITAB_BSEG-SHKZG TO I_BSIS-SHKZG,
           ITAB_BSEG-MATNR TO I_BSIS-MATNR,
           ITAB_BSEG-WERKS TO I_BSIS-WERKS,
           ITAB_BSEG-MENGE TO I_BSIS-MENGE,
           ITAB_BSEG-BEWAR TO I_BSIS-BEWAR,
           ITAB_BSEG-DMBTR TO I_BSIS-DMBTR,
           ITAB_BSEG-KTOSL TO I_BSIS-KTOSL,
           ITAB_BSEG-XREF3 TO I_BSIS-XREF3,
           ITAB_BSEG-PEINH TO I_BSIS-PEINH,
           ITAB_BSEG-EBELN TO I_BSIS-EBELN,
           ITAB_BSEG-EBELP TO I_BSIS-EBELP.
       IF ITAB_BSEG-SHKZG = 'H' .
         I_BSIS-DMBTR = I_BSIS-DMBTR * -1.
         ITAB_BSEG-DMBTR = ITAB_BSEG-DMBTR * -1.
       ENDIF.
IF NOT I_BSIS[] IS INITIAL.
      SELECT * FROM MSEG
      INTO CORRESPONDING FIELDS OF TABLE ITAB_MSEG
      FOR ALL ENTRIES IN I_BSIS
      WHERE MBLNR = I_BSIS-MATDOC
      AND   MJAHR = I_BSIS-MATDOC_YEAR
      ORDER BY PRIMARY KEY.
     LOOP AT ITAB_MSEG.
       LOOP AT I_BSIS WHERE MATDOC = I_MSEG_WE-MBLNR. "AND MATDOC_YEAR = I_MSEG_WE-MJAHR.
         MOVE :
            ITAB_MSEG-BWART TO I_BSIS-BWART.
         MODIFY I_BSIS TRANSPORTING BWART.
       ENDLOOP.
     ENDLOOP.
IF WA_ZBW_MM_PPVCALC-BWART = '    '.
MATDOC_YEAR = WA_ZBW_MM_PPVCALC-AWKEY+10(4).
     MATDOC = WA_ZBW_MM_PPVCALC-AWKEY(10).
      SELECT * FROM MSEG
      INTO CORRESPONDING FIELDS OF TABLE ITAB_MSEG2
     FOR ALL ENTRIES IN I_BSIS
      WHERE MBLNR = MATDOC
      AND   MJAHR = MATDOC_YEAR
      ORDER BY PRIMARY KEY.
  LOOP AT ITAB_MSEG2.
  WA_ZBW_MM_PPVCALC-BWART = ITAB_MSEG2-BWART.
  ENDLOOP.
  ENDIF.
Please let me know where I need to change the logic to pick all movement types documents.
Thanks,
SAP_BI_AP
Edited by: SAP_BI_AP on Jun 23, 2010 10:35 PM

Hi
There is one std tcode COOIS where u can get the information what u have asked
Pls check
regards
Vijay

Similar Messages

  • Include Movement Type into FBL3N and NA into MB51 (SAP report).

    Hi SAP Gurus,
    1.Is this possible to Include Movement Type into FBL3N, if You guys know that pls let me, what are the steps require.
    2.Enhancement to existing SAP report, t-code:KOB1 to include standard cost,  std quantity, actual cost, actual quantity by part details and assembly part number in SE & SR document type
    Guys please help on this.

    Hai
       i thought u require the layout which give report like FBL3n ,not in standard lyout which u insert field.
    then go path in clude it required field  
    Financial accounting /genaral ledger accounting/gl accounts/line items/display line item. where u may go for new field to
    insert like by new entries..not only for gl,u may search for ap,ar, also get this type configuration for respective path.
    clear

  • ABAP Code to get Production Order Quantity for a material-Status REL,CRTD

    hi all,
    I am new to SAP. I am stuck with a problem while writing a abap code for getting all the production order quantities for a material with System Status REL and CRTD. Please help me out. This is what i tried to do.
      IF t_mat[] IS NOT INITIAL.
        t_mat2[] = t_mat[].
        SORT t_mat2 BY matnr.
        DELETE ADJACENT DUPLICATES FROM t_mat2 COMPARING matnr werks.
        SELECT auaufnr afgamng af~plnbez INTO CORRESPONDING FIELDS OF
        TABLE t_ord1 FROM afko AS af INNER JOIN  aufk AS au ON
          afaufnr = auaufnr
        FOR ALL ENTRIES IN t_mat2
        WHERE af~plnbez = t_mat2-matnr
        AND   au~werks  = t_mat2-werks
        AND   af~gltrs IN s_gltrs
        AND   af~gstri IN s_gstri
        AND   au~phas0 IN s_phas0
        AND   au~phas1 IN s_phas1.
      ENDIF.
    Thanks. Regards.
    Sandeep

    Hi
    There is one std tcode COOIS where u can get the information what u have asked
    Pls check
    regards
    Vijay

  • Combine below 3 movement types into 1

    Hello Gurus
    The requirement is to combine below 3 movement types into 1.
    1)       Blocked Stock/Q Stock to Unrestricted Use.
    2)       Unrestricted use to Sales Order Stock.
    3)       MB1B from 2010 to 3000.
    Will Appreciate your responce on this..

    Can you explain what is the business purpose?
    You cannot combine these movements and create just one movement.
    But you can develop custom ABAP transaction which can perform these three movements at a time.

  • Combining 3 Movement types into 1

    Hello Gurus
    The requirement is to combine below 3 movement types into 1.
    1) Blocked Stock/Q Stock to Unrestricted Use.
    2) Unrestricted use to Sales Order Stock.
    3) MB1B from 2010 to 3000.
    Will Appreciate your responce on this

    You can write a new Z transaction, behind it you call BAPI_GOODSMVT_CREATE 3 times, one for each movement.

  • Get a movie clip into a presentation

    I am very new to Apple community and just purchased Keynote. I have a Knote presentation and want to use clips from movies i.e. "A Beautiful Mind" to help teach about psychiatric issues. Can this be done? I just read about CINEMATIZE 2, but I am not sure I understand the concept of encrypted and unencrypted DVD's. Thank you.
    G5   Mac OS X (10.4.3)  

    Well, if you can get past the issue that it's technically illegal to break the encryption from a DVD (meaning, though it might be legal to use the clip in class, it's not legal for you to actually get a usuable clip, except to just play the dvd in class and stop it when you need to).
    Anyway, there's a Mac app called handbrake that rips dvds into Mpeg4 and iPod formats, and there's also a mac app that will decrypt a dvd, and copy it to your hard drive, where you can use other apps to rip it into DV or another format. It's called Mac the ripper.
    Hope that helps

  • What's the best way to use QR codes to get v-card information into iphone contacts?

    I want to put contact/v-card information onto a business card with a QR code. I'm finding that the iphone won't accept v-cards natively, that I have to set up the QR code to go to a URL, which tells the scanner that if they enter their email address, it will email them my v-card. This defeats the purpose of putting a qr code on a business card - to scan it directly into contacts.  What is the workaround?

    I'll try to help a bit.
    ITunes match space is different to icloud space. With iTunes match you get storage for 25,000 non iTunes purchased tracks and other than a limit for individual file size, there is no memory limit.
    You can turn match on individuallyon each device (I have it turned off on my iPod but turned on on my iPad and iPhone). When you turn it on then you get access to all the tracks, and in my experience any playlists I create have transferred over very well. I understand that some people have had trouble with playlists though.
    I'm not quite clear with exactly what you mean regarding cleaning up your library, but be careful about using Match for this. There is no guarantee that matched songs will be exactly the same version as your own copy, due to some mismatches, so you could find some problems there. Personall, I am cleaning up my library before matching, but I am rather particular about keeping my library the way I want it. If you aren't as fussed then match could be the answer.
    Hope that helped.

  • ABAP Code not getting executed through process chain

    Hi Friends,
      I have program which when executed with respective varient Popup system message (SM02 Messages).  This program work fine when executed in forground or in background.
       However same program when i added in process chain with respective varient. The output is not genertaed as expected (i.e the program is not populating SM02 message)
      The process chain work's fine without giving any error.
    Does any setting we need to do ???
    i have followed the procedure given in "How to…
    Integrate an ABAP program in a process chain" document from OSS.
    Regards,
    Jayant.

    Hi,
    you will not see in the log of the process chain if your program failed or not. You only receive a message that the programm has been triggered successfully.
    Your program is then started in a new background process with a new log - try to find it via the job overview (transaction SM37) via date and time selection. (Of course you can only find there what your program writes to the log).
    Another idea would be to check the profile of user ALEREMOTE (Transaction SU01 or SU01D) if there is an authorization for transaction SM02.
    Stephan

  • How to display two movement type for same PO no.in same row in alv grid.

    Hi All
          I have one PO no suppose 1812006400 which have 2 movement type(BWART) suppose 101 & 351 i want to show the both movement
    type in one row.now in my case its showing two different row.i made 1 seperate column in final internal table i.e. movement type2.Plz help us.
          Kindly see attachment..

    Hi Samadhan,
    Try the following code for merging the Movement type into single row using Control Break statements(AT END OF...AT END).
    "Sort the internal table based on PO Number and movement type
        SORT IT_TABLE BY PO_NUMBER BWART.
    "Process the LOOP.
       LOOP AT IT_TABLE INTO WA_FINAL.
         WA_FINAL-PO_NUMBER = WA_TABLE-PO_NUMBER.
         "Merge Movement type
         IF WA_FINAL-BWART IS INITIAL. 
          WA_FINAL-BWART = WA_TABLE-BWART.
         ELSE.
         CONCATENATE WA_FINAL-BWART '/' WA_TABLE-BWART INTO WA_FINAL-BWART.
         ENDIF.
         AT END OF PO_NUMBER
          FLAT_END = 1.
         ENDAT.
         IF FLAG_END = 1.
          APPEND WA_FINAL TO IT_FINAL.
          CLEAR: WA_FINAL,
                       FLAG_END.
         ENDIF.
        ENDLOOP.
    Regards
    Rajkumar Narasimman

  • How to read Filter selection variable values into ABAP code

    HI IP Gurus,
    Requierement: In my filter characterstics, i have assigned variables, which use will enter when running th e planning sequence.
    so  variable values entered by user , i would like to get those values into ABAP code and pass them to some function module.
    SO please give me step by step detail how to achive this.
    MY understanding use the below method . but not sure how to proceed.Please let me know abap code to get values.
    GET_TAB_PARAM_DATA_SEL and GET_PARAM_DATA_SEL.
    Please help me.
    Thanks in advance.Will Assign points
    Sania

    Hi Srinivas,
    So In RSPLF1 , in paramters tab, Do i have create structure(str1) and then create component Data selection (Dtsel1) under str1(what setting i have to do here, where should i enter variable value and do i need to give info object name and how do it in code.i tried to following example, not able to get any values in tab_sel .
    It will be great, if you could explain in detail.
    other thing i found out is in Initialization method i can read i_t_data_charsel table values , where it contains filter slected values.but could not pass  these values to execute method
    Is there is any way that i can pass values from init method to execute method.
    A tabular structured parameter with name "MY_TABSTRUC" is defined for the function type. "MY_TABSTRUC" consists of the two parameter components "MY_ELEM" and "MY_DATASEL". You access the parameter values as follows:
    DATA: TAB_PARAM_STRUC TYPE RSPLFA_T_PARAM_STRUC,
           REF_PARAM_STRUC    TYPE REF TO IF_RSPLFA_PARAM_STRUC,
          REF_PARAM_ELEM     TYPE REF TO IF_RSPLFA_PARAM_ELEM,
          REF_PARAM_DATASEL  TYPE REF TO IF_RSPLFA_PARAM_DATESEL,
           L_VAL(20)          TYPE C,
           TAB_SEL            TYPE RSPLF_T_CHARSEL.
    get table of parameter MY_TABSTRUC:
      TAB_PARAM_STRUC = I_R_PARAM_SET->GET_TAB_PARAM_STRUC( 'MY_TABSTRUC' ).
    process all lines:
      LOOP AT TAB_PARAM_STRUC into REF_PARAM_STRUC.
      get component MY_ELEM:
        REF_PARAM_ELEM = REF_PARAM_STRUC->GET_COMP_ELEM( 'MY_ELEM' ).
      get internal value of MY_ELEM:
        REF_PARAM_ELEM->GET_VALUE( IMPORTING E_VALUE = L_VAL ).
      get component MY_DATASEL:
        REF_PARAM_DATASEL = REF_PARAM_STRUC->GET_COMP_DATA_SEL( 'MY_DATASEL' ).
      get data selection table of MY_DATASEL:
        TAB_SEL = REF_PARAM_DATASEL->GET_T_SEL( ).
      ENDLOOP.
    Thanks in Advance..please help me

  • Reg: i want to get nagative values for movement type 102

    Hi All
    I have developed  a report
    in that report
    output fields are
    po no     mater docment no  movement type   qty     netprice
    500023     4990                         101              10       100
    500024     4556                         102               12       200
    this is the output i am getting.
    for movement type 102 i want to get the nagtive  values .
    example
    po no     mater docment no  movement type   qty     netprice
    500023     4990                         101              10       100
    500024     4556                         102              -12     - 200
    pls can u help
    who to write logic
    thanks
    mars

    hi,
    use this.
    loop at itab.
    if itab-bwart = '102'.
    itab-menge = - ( itab-menge ).
    itab-netpr = - ( itab-netpr )
    endif.
    endloop.

  • Blocking Movement type 122 for T code MBRL

    All SAP Gurus,
    I want to block the movement type 122 for T code MBRL.
    For this I used T code OMJJ, but here it is not showing MBRL as used T code.
    If MBRL is not specified in OMJJ for 122, then how MBRL T- code is allowed for movement type 122.
    Please give ur valuable inputs.
    Regards,
    Edited by: Rajan R. on May 19, 2008 10:22 AM
    Edited by: Rajan R. on May 19, 2008 10:59 AM

    Check the all authorization roles you have created for inventory management. In there you can take out MBRL from the list. Then, create a new role for transaction MBRL only, and then you can allow other movement types for this role except 122. Assgin this role to your users.
    This is what I have done at two client locations.

  • Block Movement type 122 for T code MBRL

    All SAP Gurus,
    I want to block the movement type 122 for T code MBRL.
    For this I used T code OMJJ, but here it is not showing MBRL as used T code.
    If MBRL is not specified in OMJJ for 122, then how MBRL t code is allowed for movement type 122.
    Please give ur valuable inputs.
    Regards,
    Edited by: Rajan R. on May 17, 2008 3:22 PM

    Hi
    Thanks for the reply
    Now I want to block movement type 122 so that it can not be used throuh MRRL, is it posssible and how to do that?
    I have alredy blocked MIGO for movement type 122
    Edited by: Rajan R. on May 17, 2008 3:51 PM

  • Reason for Movements for selected movement type in MB1A/B/C

    All,
    When a user goes to MB1A, MB1B, MB1C and selects a movement type is there a way to show only the reasons for movements for that selected movement type?
    Currenlty, when the users clicks F4 or wants to view the options available for reasons for movements, it shows them EVERYONE movement type and its associated reason for movement. The list is HUGE. So, I want to know to shorten the list to show only the applicable ones for the movement type the user has selected.
    I know the user can enter the movement type and the list gets filtered but this is a manual step the user must perform. Is there any way the system can restrict the reasons for movements based off the Movement Type already selected by the user?
    Please let me know how to show only those reason codes for the selected movement type in transactions MB1A, MB1B, and MB1C.
    Thanks for your help in advance!

    To shorten the list you can select the movemnt types the user requirs and make his/her personal list so when he.she do f4 onlt personal list will be displaed.
    U can create personal list by doing the F4 and put cursor on movement type and below will be icon to add into personal list.after selecting all the movement types. close the window and adain do f4 u will only see the entries of u r personal list.

  • Movement Type and Its Reversal

    Hi all,
    In Sub contracting scenario-
    541-  Transfer posting to Stock with Sub contractor from unrestricted stock.
    542- Transfer posting to Stock with Sub contractor from unrestricted stock Reversal
    I want to know does 542 means TP from subcontracting stock to Unrestricted stock.
    Which scenario i can used 542 to movmnt type?
    How the GR and Byproducts, scraps are  is handled in Sub contracting.
    Regards,
    Ashu

    Hi
    3 diff scenarios you may use 542 movement type...
    1)You are sending some component to SC-vendor...for assembling against SC-PO...
    Now the Order has been cancelled...you want to cancel the SC-PO, and take back the Component from SC-Vendor...Now you have to take back the Components from SC-Vendor in T.Code:MB1B,useing 542 movement type only....
    2)Suppose you have issued some Components to SC-Vendor against SC-PO for making one assemble....Now the SC-Vendor has consumed the Component less compare to our Estimation(what we maintained in BOM)...
    So Now you have to take back the Bal.qyt. of component fron Sc-vendor....for this purpose...First you have to Do regulr GR for the Finished assembly....and separately, you have to do Sub.Adjustment in MIGO, with ref.doc.as Your SC-PO....the Under consumed component will be adjusted in 544 O+ movement type automatically....and this Under Consumed bal.qty.Components you have to get back into Company stock in MB1B,useing 542movent type...
    3)If you want to get By product from SC-Vendor.....then you can get back by useing 542movement type only...
    If you want to get By product from SC-Vendor.....you have to maintain while creating BOM itself...
    For eg) you give Product "A" to SC Vendor and getting back Product "B"...and By product "C"....
    Then Create BOM for Product "B" in CS01...and in Components list...you give Product "A" , and maintain Product "C" as a negative component(ie) By product..)
    Then Create PO for Product "B" in ME21N with Item Category "L"....
    Then Issue Product"A" to SC-Vendor in ME2O///
    After completion of product "B"....you do GR for Product "B"...in MIGO 101+ movement type....
    At this time, the Component, Product"A"...will be automatically consumed in 543 O-- movement type...and your By Product will be generated in 545 O+ movement type and it will be lying at SC-vendor's Place....
    Then separately, you can Get back this By product in to Company's stock in MB1B movement type....useing movement type 542....
       I think I have clarified all your questions...
    Reward if useful
    Regards
    S.Baskaran

Maybe you are looking for