11 Replies Latest reply: May 26, 2013 11:25 PM by Jürgen L RSS

LSMW - update Z Table

Jeanette Baunsøe
Currently Being Moderated

Hi experts

I know this question has been asked several times and I have read some of the treads.

Unfortunately I have not found THE answer.

 

I have a Z-table, without maintenance view! - We are operating in production system, and the update is a one-time shot. So it makes no sence to create a maintenance view which must be transported, otherwise I could as well create a small ABAP.

 

I would like to update this file using LSMW with direct update. Is it possible at all....???

 

How can I "define" the target structure which should  be my Z-table?

 

One of the threads I have read says that I could use a dummy recording and then do the update using conversion rules. But I get stuck when it comes to fill the transfer record.

 

Here the full text: You're not using Direct Input - use Batch Input. Like I said, it doesn't matter what BDC recording you choose in the first screen because you're never going to get to that step anyway (if you don't have one just create a dummy one for any transaction, preferably a short one). In your conversion rules, choose any of your BDC fields and write code to update the table for each record in the file (Create Rule button -> ABAP code). You don't need to do anything with the other fields.

 

Read the data then Convert the data. The Convert step will update your Z-table, assuming you have set up your file structure and code correctly.

 

LSMW can do anything as long as you're creative enough

 

Pls help. It is getting a bit urgent.

 

Br

Jeanette

  • LSMW - update Z Table
    Jürgen L
    Currently Being Moderated

    go into your LSMW

    create a recording of SM30 for maintainance of your Z-table

    Create source structure

    define the source fields

    assign source to target structure

    go into field mapping and do your field mapping as usual

    at __END_OF_RECORD__

    add a little ABAP coding:

    move source field   to target field in a working structure .

    .    INSERT INTO your Z-table  VALUES working structure .

    transfer_record.

     

    specify your file

    Assign the file

    Read the file

    Convert the file

    your are done, no need to do anything more, because the convert step has already updated your Z-table. you do not need to create a batch input session.

  • LSMW - update Z Table
    Jeanette Baunsøe
    Currently Being Moderated

    Hallo Jürgen

    Thank you for your prompt reply!

    I followod your guide, but still have a problem though.

     

    You tell me to map the fields as usual. But I do not see the fields of my Ztable......

    Is that correct or not?

     

    My coding seems to be all right, but the ztable is not updated. Because of the missing mapping?

     

    brik coding.JPG

    After the insert into ztable, the values are TABNAME = ZBRIK  TCODE = SM30.

     

    what am I missing?

     

    Br

    Jeanette

  • LSMW - update Z Table
    Jeanette Baunsøe
    Currently Being Moderated

    First I need to thank you so much for your time and help. Really appreciate it!!!!

     

    Tried to declare the table in global data, but that resultet in syntax error (table already declared).

     

    No, the converted data does not contain the fields.

    That confuses me. When I check the relations it shows structure ZBRIK. When I click the structure it shows the total table with all its fields.

     

    structure relations.JPG

    table zbrik.JPG

     

    But the converted data looks like this.....

    Converted data.JPG

    The data definition of the code:

     

       * Target structure definitions
    data:
      begin of ZBRIK occurs 0,
        TABNAME(000030) type C,
        TCODE(000020) type C,
      end of ZBRIK .
    data:
      init_ZBRIK like ZBRIK,
      prev_ZBRIK like ZBRIK.

    * Source structure definitions
    data:
      begin of LSMW_BRIK_INPUT,
        BRIK_ID(010) type C,
        CONTRACT(010) type C,
        CONTRACT_ITEM(010) type C,
        ZZSUPPLY_CODE(001) type C,
      end of LSMW_BRIK_INPUT.

     

    Need to somehow add the missing fields to the structure - a desperate try could be to add them to the code, but will it work, you think?

    brik coding.JPG

     

     

    • LSMW - update Z Table
      Jürgen L
      Currently Being Moderated

      Sorry, I am a kind of braindead. The converted data could not be different than you have. The fields do not play any game as we dont need those records.

      But the schreen shot of your converted data proofs already that the program ran through this statement.

       

      I have just a guess ( I am not a good ABAPer - just as much as I need for LSMW), it may be that SAP gets confused with the same name for the table and for your target structure (which is automatically coming from the recording) .

      so the structure ZBRIK has just the 2 fields for TABNAME and TCODE

      while the table ZBRIK has much more fields

       

      Can you try another recording and name it ZZBRIK or ZBRIK2, which would make the structure name different from your table name.

      • Re: LSMW - update Z Table
        Jeanette Baunsøe
        Currently Being Moderated

        Hi Jürgen

        Yes I also noticed in my trials, that if I did not name the recording the same as the table, it would not have the structure,,,,,

         

        I started all over again. Named the recording something different (brik_sm30)

        Maintained step 2, 3 and 4.

        In the mapping I declared the table under "global_data":

        Selected the records from Ztable, moved new values to the fields and updated the table.

        Now it seems to work.

         

        The weird thing is that I did this in a previos try, the only difference was then that the recording was called the same as the Ztable and that the table was not declared under global_data. 

        So the lesson learned here must be do not name the recording the same as a database table.

         

        Final code.JPG

         

        Thank you for sparring with me.

         

        /Jeanette

         

        Message was edited by: Jeanette Baunsøe Would like to give point, but how do I do that?

        • Re: LSMW - update Z Table
          Thomas Zloch
          Currently Being Moderated

          Would like to give point, but how do I do that?

          Seems you figured it out, marking replies as helpful and correct does it. Well deserved

           

          That's why the security guys "love" it, you can inject any code in the production system if you have LSMW authorization...

           

          Thomas

          • Re: LSMW - update Z Table
            Jürgen L
            Currently Being Moderated

            I do have LSMW authorization , and the status Toxic

            Serious, not many have LSMW authorization in our system, not even in the development system. The authorization is only granted for the project time, we have to apply for the authorization with each new project, and get only the permission for the objects nominated in the scope.

Actions