LSMW field mapping Rule-ABAP code

Dear Guru!
I'm new to ABAP, but I have to write a little in ABAP.
I create a LSMW project using BAPI for changing standart price of material.
Input data: material, price, posting date.
The point is: system should found in table MBEW all valuation areas and valuation types fo which the material record is exist and cang price for all these records.
I wrote a code for these fields in Field Mapping menu. But it puts in only one record whereas I need it to execute BAPI for all records.
I wrote the folliwing:
VALUATIONAREA                Valuation Area
                   Code:    tables MBEW.
                            select * from MBEW
                             where MATNR = ZHEADER-MATNR.
                            E1MATERIALVALUATION_PRICECH-VALUATIONAREA = MBEW-BWKEY.
                            endselect.
VALUATIONTYPE                Valuation Type
                   Code:    select * from MBEW
                             where MATNR = ZHEADER-MATNR.
                            E1MATERIALVALUATION_PRICECH-VALUATIONTYPE = MBEW-BWTAR.
                            endselect.
May be it's simple, may be not. But I don't know how do do it.
Will be grateful for any hints.
Thanks.
Edited by: assoli on Aug 3, 2011 3:51 PM

select endselect goes like a Loop, so if you don't store the value in some table (internal table), only the last row will be available to you as it will be overwritten everytime in the loop.
There is no need of using 2 selects, one select itself will give you all the data for that material in MBEW table. I don't understand what you are doing with
E1MATERIALVALUATION_PRICECH-VALUATIONAREA = MBEW-BWKEY
Is E1MATERIALVALUATION_PRICECH a structure ? You need somethng like
select * from MBEW
where MATNR = ZHEADER-MATNR.
E1MATERIALVALUATION_PRICECH-MATERIAL             = ZHEADER-MATNR
E1MATERIALVALUATION_PRICECH-VALUATIONAREA = MBEW-BWKEY.
E1MATERIALVALUATION_PRICECH-VALUATIONTYPE = MBEW-BWTAR.
Append E1MATERIALVALUATION_PRICECH to itab.             "(itab is internal table)
endselect.
Then use that itab for your purpose.

Similar Messages

  • Re: Error in LSMW Field Mapping and Conversion Rules

    Hi Friends,
    In Step Field Mapping and Conversion Rules:
    Am not able find the fields.
    1. I checked the source structure relationship it is ok.
    2. I have assigned the fields in recording too.
    Please help me out.
    Thanks in advance
    vivek

    hi ram,
    I think u have gone wrong in the first step itself............
    Do like this,
    1) Goto Maintain Object Attributes
    2) Select Batch Input Recording and Enter Ur recording Name
    3) Then Select Recording Overview...
    4) Thne Press DEFAULT ALL on ur Application Toolbar or Select EDIT-> DEFAULT ALL
    5) All ur Source Fields will be mapped for Recording Fields......
    6) Now u can see ur Fields in Field Mapping and Conversion Step......
    I hope this will work u r doing with BATCH INPUT METHOD...
    Reward me if useful.......
    Harimanjesh AN

  • LSMW  Field Mapping: can't map Batch Input Structure for Session Data

    In step 5 Maintain Field Mapping and Conversion Rules, I can not see Batch Input Structure for Session Data Fields.
    Can somebody tell what's wrong?
    Here's what I see:
    Field Mapping and Rule
            BGR00                          Batch Input Structure for Session Data
                Fields
                BMM00                          Material Master: Transaction Data for Batch Input

    Hi Baojing,
    To see structure BGR00  you have to map this structure first with input file structure in step 4 (maintain structure relationship).
    Regards
    Dhirendra

  • LSMW field mapping

    Hello,
        I am doing Material master load using LSMW in 3loads.
    First load is for basic data with matnr , mtart,mbrsh,maktx,meins,bismt,mtart.
    wht should be the format of my input file, it should be like in the step " maintain field mapping and conversions" , because when in see the data in "display read data " and " display converted data ", its loading the records but its deleting some parts of it and after executing the last step its giving errors.
    If LSMW is success, where can i see the output?
    I would appreciate if some can help me , i am doing LSMW for the first time.
    the problem is with field mapping and file format?
    thanks.
    Raghu

    the file format is same as the field mapping and conversions, still its picking the values from the file in different order . I am saving the excel sheet in tab delimited form and mentioned it in the LSMW.if anyone done Material master load , if would appreciate if u can give the steps and file format..
    points are rewarded..
    thanks.

  • ABAP code which will use function module during field mapping in LSMW

    Hi,
    During field mapping in LSMW, for one of the field called field, I want to use a function module 'QF05_RANDOM_INTEGER', which will generate random numbers and map that random number to that field.
    How do I write ABAP code which uses function module, during filed mapping for a particluar field in LSMW ?
    Please help...
    Regards,
    Tushar.

    Hi Tushar,
    You can write in FORM ROUTINE and LSMW.
    I hope you know how to write ABAP code at field level.
    If not ...
    Come to change mode->select the field->Rule->ABAP Code
    write a perform statement in ABAP code at field level.
    <b>PERFORM test</b> using val
                 changing valu.
    Go to Utilities(at menu)->switch layout-> extras ->select Layout->check Form routine-> it will display a FORM Routine... at bottom
    this is the place where you can write some code for
    <b> FORM test</b> using value
              changing value1
      FM call....
    .ENDFORM  
    Get the value1 returned and use for the Field population.
    Reward points if this Helps.
    Manish
    Message was edited by:
            Manish Kumar

  • LSMW (ABAP Code Rule)

    Hi All,
    I have to upload data in transaction code MD61 (Planned Independent Requirement) for a year, that is, 12 months.
    The requirement date and planned quantity have fields EDATU & PLNMG, respectively. If I'm going to input 12 months, the fields will become EDATU_01, EDATU_02... EDATU_12 and PLNMG_01 to PLNMG_12. However, the screen during background processing only has 10 rows, resulting to an incorrect session in SM35 with error: "Field RM60E-EDATU(11) does not exist in the screen SAPLM60E 0200".
    Is there a way that I can use ABAP Code in LSMW's conversion rules for me to be able to upload 12 entries in MD61?
    Thanks a lot in advance!
    Best regards,
    Olyn

    Hi,
    While recording did you come across the 11th and 12th row as well?
    if not, once the recording is done try to insert those two in the  recording list manually. And then in the field mapping try to map this with the 11th and 12th field you have in your structure.

  • Maintain Field Mapping and Conversion Rules//LSMW

    Hello Friends,
    I want to add new fields in the step.no.5(Maintain Field Mapping and Conversion Rules).
    Indetail i'm going to upload the GL balances, for DR and CR line item fields are same so system is not accepting the same field value, so i have added 1 for the CR line item fields like in the below example.
    BSEG-WRBTR(Dr line item)
    BSEG-WRBTR1(Cr line item)
    but BSEG-WRBTR1(Cr line item) field not displaying in the step.no.5 to mapping to source field.
    please let me know the solution for this.
    thanks
    swapna.

    Hi,
    I would like to ask few questions.
    1. Are you using batch input recording or using any program for uploading. (through LSMW)
    2. Whether all your debit or credit line items are same every transactions. I believe they should be same, because you are uploading the balances.
    You should not have two similar fields for example, if it is WMBTR, then again WMBTR should not be there, it should WMBTR1 and WMBTR2. Make sure you have done the field mapping properly. When you have done the field mapping all the fileds must have been mapped. If any one of the fields are not mapped, then it will not be uploaded.
    Please see the following LSMW sample guide:
    http://www.scmexpertonline.com/downloads/SCM_LSMW_StepsOnWeb.doc
    Maintain Object Attributes Do the recording - Make sure that you do not have two fields with the similar name. If you have two fields with the same name double click on the field name and add1 or 2 to differentiate between field names. Just Copy those fields and descriptions in excel sheet, delete the blank lines, then in excel data => text to columns, your field names and descriptions will be now in two columns. Copy them, then put your cursor on the next sheet, then edit => Paste Special => Transpose, all the columns will become your rows. Now your file structure is ready. Maintain Source Structures Give some unique structure name and description Maintain Source Fields Here you add the fields that are being used in EXCEL first sheet, just copy them and make all the fields as C (Constant) and then give length of 60 for all fields. Maintain Structure Relations Though structure relations are already created just go to this step, click on edit, then click on create structure relation, just accept the message stating that the structure relation has already been created. Maintain Field Mapping and Conversion Rules Do the field mapping for all the fields, all the fields willl be stretched and you will see five rows against each row. In case if there is any row that has NOT stretched means, there is something wrong in the mapping. Maintain Fixed Values, Translations, User-Defined Routines There is nothing to be done at this step. You can simply ignore this. Specify Files Make you must have saved your excel file as .txt (before saving make sure you have copied data from sheet2 to sheet 3 and then sheet 3 is saved at tab delimited file. Text (Tab delimited) Select your file, make SURE that you have select "TABULATOR" radio button and say OK. Assign Files Go to this step and click on Create assignment button and accept the message and say ok. Read Data Remove two check boxes and just click on execute button. See the log. Make sure you have number of entries (lines) in your excel file are matching with this. Display Read Data Display data give 1 to 999 lines and double click on one of the line and see whether fields are mapped correctly are not. Convert Data Execute and see the log match the number of entries. Display Converted Data Display converted data, give 1 to 999 and double click on one of the line and see whether fields are mapped correctly or not. Create Batch Input Session Check on Keep Batch Input sessions check box, then execute. If you select that check box, even after execution it will be there and you can analyze what happened. Run Batch Input Session (Takes you to SM35) Go to SM35 select the batch and click on process button (execute), make sure you have checked right hand side first three check boxes and FOREGROUND (because you want to save what it is creating) Say OK Keep on press ENTER on your key board in order to move the session further. If you follow these steps along with the guide, surely you should be successful. There may be small difference between the file and what I have explained but ultimately the purpose is same. Hope this is useful and let me know in case if you have any issues.
    Regards, Ravi

  • Problem in lsmw. step: display field mapping and conversion rule

    hi,
    The IDOC structure to be mapped is missing in step 5[lsmw using IDOC]. Hence target structures are missing in auto gnerated conversion program.
    As a result the the step Convert Data step is failing.[Converted data cant be generated]
    I am using standard BAPI charcteristics as my Basic Type.
    Anyone having idea why the target structure is missing??..

    The problem is solved....The field mapping was missing coz i didnt assign the target structure properly....

  • How to insert abap code in LSMW generated program?

    hi,
    i m working on LSMW for loading data in SAP
    i would like to insert abap code into the generated program....
    it's because i have 1 BKPF segment (header data), 2 BSEG segments, but i cannot define rules by customizing for the second BSEG segment(LSMW doesn't permitt).
    i already tried to insert code directly into the program, but obviously it disapears at each time i generate the program.
    i saw that apparently a code insertion has already be made into this program and the subject of this insertion is to define rules for the second BSEG (exactly what i want to do....) and this modification doesn't disapear at new prog generation.....
    Any idea ?

    Hi
    Why dont you use the FORM provided by LSMW
    To use this please do the following
    1.Goto option <b>Maintain Field Mapping and Conversion Rules</b>
    2.Goto menu <b>EXTRAS->LAYOUT->Form Routines</b>
      Here you will now get many options like
       Global Data
       Begin of Transaction
    Begin of Processing
    Begin of Record
      like wise the End of these also.
    Please put a breakpoint and check where you want to insert your code.
    Note:
    This is only for the Conversion Program and does not affect the main program used to update the Standard Tables
    Hi , I was reading your earlier post .. It seems that you have worked on EMIGALL. Consider a similar situation, it is like writing the code in the events till CALL01...
    Thanks
    DOminic
    Message was edited by: Dominic  Pappaly

  • Problem with abap code in lsmw.its urgent

    Hello guys iam migrating open ar line items using lsmwand i need to create reconciliation key automatically so iam using below code which is working fine in abap editor but i inserted in the lsmw abap code block at step 5 mapping fields iam getting error as that function module does not exits .can any body go through the code and give me suggestion.your will be greatly appreciate.
    types: begin of ty_fikey,
           fikey type fikey_kk,
           resob type resob_kk,
           end of ty_fikey.
    data: wa_fikey type ty_fikey.
    CALL FUNCTION 'FKK_FIKEY_CHECK'
      EXPORTING
        I_FIKEY                      = 'jana56481'
      I_OPEN_ON_REQUEST            =
      I_OPEN_WITHOUT_DIALOG        =
      I_FOR_MASS_POSTING           =
       I_RESOB                      = '24 '
      I_RESKY                      = ' '
      I_NON_EXISTING_ALLOWED       = ' '
      I_FOR_POSTING_IN_UPD         = ' '
    EXCEPTIONS
      NON_EXISTING                 = 1
      OTHERS                       = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    select single  fikey resob from dfkksumc into corresponding fields of wa_fikey where resob = '24'.
    e1bpdfkkko-fikey = wa_fikey-fikey.
    Regards
    Janapathi

    Hi,
    Refer link:
    <a href="http://www.scmexpertonline.com/downloads/SCM_LSMW_StepsOnWeb.doc">http://www.scmexpertonline.com/downloads/SCM_LSMW_StepsOnWeb.doc</a>
    Pls do reward points.
    Regards,
    Ameet

  • LSMW  Maintain Field Mapping

    Hi SAP Gurus,
    I maintainance LSMW with option recording
    1)     Recording trans action as92
    2)     Maintain Object Attributes with my recording
    3)     Maintain Source Structures
    4)     Maintain Source Fields
    5)     Maintain Structure Relations, between SAP and source structure, choose Check to examine the structure relationships for errors. Yes ok.
    6)     Maintain Field Mapping and Conversion Rules, and now I have trouble, because I havenu2019t screen with field. I canu2019t doing mapping.
    Maybe is any buttom/function which join sap structure with my structure
    Can anyone help me?
    Regd
    Stenwa

    perhaps je have to delete the recording and do a new recording.
    Have you done the following steps
    Maintain Object Attributes
    Go to change mode
    Go to  recordings overview:
    A recording should look like this:
    AS91       asset legacy transfer
               Transaction:         AS91 Create Old Asset
               Owner:              
    SAPLAIST 0105
        BDC_CURSOR                     ANLA-BUKRS
        BDC_OKCODE                     /00
        ANLA-ANLKL                                          ANLKL                asset class
        ANLA-BUKRS                                          BUKRS                company code
    SAPLAIST 1000
        BDC_OKCODE                     /00
        BDC_SUBSCR                     SAPLAIST
        ANLA-ANLN2                                          ANLN2                asset subnumber
        BDC_SUBSCR                     SAPLATAB
        BDC_SUBSCR                     SAPLATAB
        BDC_SUBSCR                     SAPLAIST
        ANLA-TXT50                                          TXT50                asset description line 1
        ANLA-TXA50                                          TXA50                asset description line 2
        ANLH-ANLHTXT                                     ANLHTXT              asset description line 3
    Use the SAP field names like TXA50  this you have to fill in manual
    When you record and when there are default values, still overwrite them manual (other wise you mis them here.
    Blocks
    ANLB-NDJAR(01)                                      NDJAR_01             Usefull life in years line 01
    ANLB-NDJAR(02)                                      NDJAR_02             Usefull life in years line 02
    ANLB-NDJAR(05)                                      NDJAR_05             Usefull life in years line 05
    ANLB-NDJAR(06)                                      NDJAR_06             Usefull life in years line 06
    ANLB-NDPER(01)                                      NDPER_01             Usefull life in periode line 01
    ANLB-NDPER(02)                                      NDPER_02             Usefull life in periode line 02
    ANLB-NDPER(05)                                      NDPER_05             Usefull life in periode line 05
    ANLB-NDPER(06)                                      NDPER_06             Usefull life in periode line 06
    Maintain Source Fields
    ASSET_LEGACY_TRANSFER     asset legacy transfer
        ANLKL                          C(004)    asset class
        TXT50                          C(050)    asset description line 1
        INVNR                          C(025)    asset tag number
        AKTIV                          C(010)    capitalization date
        GSBER                          C(004)    business area
        KOSTL                          C(010)    cost center
        GDLGRP                         C(008)    location
        AFASL-1                        C(004)    Asset depreciation key line 01
        AFASL-2                        C(004)    Asset depreciation key line 02
        NDJAR-1                        C(003)    Usefull life in years line 01
        NDJAR-2                        C(003)    Usefull life in years line 02
        NDPER-1                        C(003)    usefull life periods line 01
        NDPER-2                        C(003)    usefull life periods line 02
        AFABG-1                        C(010)    Dep start date line 01
        AFABG-2                        C(010)    Dep start date line 02
        ANBTR01-1                      C(013)    Aquasition value Tax books
        ANBTR02-1                      C(013)    Aquasition value LO books
        ANBTR01-6                      C(013)    *** depreciation TAX books
        ANBTR02-6                      C(013)    *** depreciation LO books
    These field names you (can) use in the header from the excel file, in some cases with the block you have 1 value in the sourche fields like use-full live but you fill it in in 3 depreciation area's in that case you have to map it manual
    When you have used the same field name's you can use in Maintain Field Mapping and Conversion Rules the option automatecly mapping
    Edited by: Paul Annotee on Apr 28, 2009 9:27 AM

  • Sample source code for fields mapping in expert routine

    Hi All
    Iam writing the expert routine from dso to cube for example I have two fields in dso FLD1,FLD2
    same fields in infocube also ,can any body provide me sample abap code to map source fields to target fields in expert routine,your help will be heighly appreciatble,it's an argent.
    regards
    eliaz

    Basic would be ;
    RESULT_FIELDS -xxx = <SOURCE_FIELDS> -xxx
    you have the source fields as source, and result fields for as the target. In between you can check some conditions as in other routines of transformation.
    BEGIN OF tys_SC_1, shows your source fields ( in your case DSO chars and key figures)
    BEGIN OF tys_TG_1, , shows your result fields ( in your case Cube characteristics)
    Hope this helps
    Derya

  • ABAP code in update rules to convert the date

    Hi,
    Could any one send me the ABAP code that is written in the update rules to convert the date (DD/MM/YYYY  -- lenght 10) to YYYYMMDD ---  length 8  format.
    Also please let me know where I should write this code; while creating update rules or while creating infosource.
    Thanks,

    Hi Bharath,
    Hi Bharath,
    I suggest you do the conversion of dates in the transfer rules. Here is the correct code you need:
    * Assuming the source data field is called MYDATE
    * Place the ff. in the routine in the transfer rules:
    concatenate tran_structure-mydate+6(4) tran_structure-mydate+3(2) tran_structure-mydate(2) into result.
    replace MYDATE with the name of the source field (10 chars) in the transfer structure. Hope this helps.

  • Convert ABAP code in start routine/update rule to transform. start routine

    Dear BW ABAPers,
    I have created a custom purchasing info cube (YCP_PURC1) based on 0CP_PURC1 standard cube. I would like to convert this new data flow to BI7 (from 3.x), and convert the standard update rule to transformation. I would need to rewrite the below start routine from the standard update rule to a start routine ABAP code in the newly created  transformation / start routine. My ABAP knowledge is limited. Will you please help?
    *this is the start routine from the update rule. As a side note, the data source is 2LIS_02_SCL.
    LOOP AT SOURCE_PACKAGE.
        IF (     SOURCE_PACKAGE-cppvlc  EQ 0
             AND SOURCE_PACKAGE-cppvoc  EQ 0
             AND SOURCE_PACKAGE-cpquaou EQ 0 ).
          DELETE SOURCE_PACKAGE.
          CONTINUE.
        ENDIF.
    no_scl is initial ( e.g. for good receipts, billing)
    value has to be set depending on storno
        IF SOURCE_PACKAGE-no_scl IS INITIAL.
          IF SOURCE_PACKAGE-storno = 'X'.
            SOURCE_PACKAGE-no_scl = -1.
          ELSE.
            SOURCE_PACKAGE-no_scl = 1.
          ENDIF.
          MODIFY SOURCE_PACKAGE.
        ENDIF.
      ENDLOOP.
    if abort is not equal zero, the update process will be canceled
      ABORT = 0.
    Many thanks and look forward to your kind feedback.
    Kind regards,
    Csaba

    Dear All, Durgesh,
    thanks to you all for your valuable input. Mainly the ABAP part was more interesting for me.
    Durgesh, thanks for your input, it was useful. I just had to change the info objects to data source fields and add the lines before the loop:
    DATA: I_PACKAGE TYPE TYT_SC_1.
        FIELD-SYMBOLS <i_package> TYPE tys_sc_1.
        I_PACKAGE[] = SOURCE_PACKAGE[].
        LOOP AT SOURCE_PACKAGE assigning <i_package>.
          IF ( <i_package>-BWGEO EQ 0
          AND <i_package>-BWGEOO EQ 0
          AND <i_package>-BWMNG EQ 0 ).
            DELETE SOURCE_PACKAGE index sy-tabix.
            CONTINUE.
          ENDIF.
    no_scl is initial ( e.g. for good receipts, billing)
    value has to be set depending on storno
          IF <i_package>-NOSCL IS INITIAL.
            IF <i_package>-ROCANCEL = 'X'.
              <i_package>-NOSCL = -1.
            ELSE.
              <i_package>-NOSCL = 1.
            ENDIF.
          ENDIF.
        ENDLOOP.
    Points have been assigned accordingly.
    Thanks,
    Csaba

  • LSMW--- I am not seeing some variables, which r using in abap code!

    Hi Experts,
    Am enhancing the LSMW---> Create_Material, so I hv some basic doubts, pls. clarify,
    1 - In the following satemenrts of the code, the programmer used my_langu(variable?), so, Where the programmer has declared(attributes & value) the my_langu ? I searched in FIXED VALUES radio button, Global data, double clicking, abap code radio button, I culd not find it!
    Target Field: E1BP_MLTX-LANGU Language key
    E1BP_MLTX-LANGU = my_fv_langu. (like theses many variables r using in the abap code, but I culd not track them to see, thrier attributes!)
    2 - In abap code, the programmer is using <b><i>skip_transaction</i></b>! but, we dont hv skip_transaction in ABAP code?
    thanq.

    Hi,
    skip_transdaction is a LSMW Global Function and not an ABAP command:
    Global function     Description
    transfer_record.     Transfers the current record (i.e. for the current target structure) to the output buffer.
    transfer_this_record '...'.     Transfers a record of another target structure to the output buffer. The name of the target structure has to be specified as argument in single quotes.
    at_first_transfer_record.     Transfers the current record to the output buffer, if it is the first transaction.
    on_change_transfer_record.     Transfers the current record to the output buffer, if it has changed compared to the last record.
    transfer_transaction.     Writes the current transaction to an output file. All records of the output buffer are transferred to the output file.
    skip_record.     The current record is not transferred to the output buffer.
    skip_transaction.     The current transaction is not written to the output file.
    I'm not sure about the my_langu(variable?).
    Hope it helps some.

Maybe you are looking for