4 Replies Latest reply: Apr 12, 2006 12:10 PM by Jonathan Maidstone RSS

Multiple Line items

parvez ahmed
Currently Being Moderated

hi all SAP gurus,

 

Iam trying to upload excel file(test data file) to va21 and va22 transcation using a chain script where iam calling these individual scripts by using REF command in eCATT editor.The issue iam facing is i have done TCD recording for va21.I have declared IT_linedata as export parameter of the type VBAP.From the test file iam capturing the line items corresponding to various quotations in this it_linedatatable.This internal table has to be exported to va21 script where i have declared this as import parameter.The problem is how to assign this itab values containing material and quantity to the command interface parameters .

      

'S'     'BDC_CURSOR'     'RV45A-KWMENG'     

'S'     'RV45A-MABNR(01)'     V_MATNR     

'S'     'RV45A-KWMENG(01)'     V_KWMENG     

 

something like above.

i need to automatically increment this command interface parameters using inline ABAP code according to items given in the test file.

 

I would highy appreciate if anyone can get back to me with the inline ABAP code.

 

I know how to do this in bdc but as iam currently working on this scenario would appreciate ur help.

 

thanks and regards,

 

parvez

ABAP consultant

  • Re: Multiple Line items
    Sapna Modi
    Currently Being Moderated

    Hello Parvez,

     

    The dynamic assigment of values in TCD is possible. Copy your excel file in a text file and save it as .txt file on your desk. The sample code is as given below.

     

    There are some points need to be followed for the errofree execution in such dynamic assignment-

    1. Open the TCD command interface in the structure editor and display the field list of the screen (Dynpro) whose fields will be modified later dynamically.

    2. Sort the field list by moving all entries with MODE  ‘I’ or ‘O’ to the end of the list, so that these fields get higher indices than the fields with MODE  ‘S’, ‘C’ or ‘G’, which are used at the TCD execution.

    3. Now you can modify the fields by using the correct indices, because the indices are not affected by the deletion of the field entries with higher index.

    -


    SAMPLE CODE WRITTEN IN Test Script Editor FOR TCD -

    -


    ABAP.

    • Internal table with the strcuture of file on desk

    TYPES: BEGIN OF IS_TAB,

             FNAME(10),

             LNAME(10),

             SNAME1(10),

             SNAME2(10),

             DOB(4),

           END    OF IS_TAB.

     

    DATA   IN_TAB TYPE TABLE OF IS_TAB.

     

     

    • Upload the file into internal table

    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD

      EXPORTING

        FILENAME                =  'C:\Documents and Settings\720783\Desktop\TEST.xls'

        FILETYPE                = 'ASC'

        HAS_FIELD_SEPARATOR     = 'X'

      CHANGING

        DATA_TAB                =  IN_TAB

      EXCEPTIONS

        FILE_OPEN_ERROR         = 1

        FILE_READ_ERROR         = 2

        NO_BATCH                = 3

        GUI_REFUSE_FILETRANSFER = 4

        INVALID_TYPE            = 5

        NO_AUTHORITY            = 6

        UNKNOWN_ERROR           = 7

        BAD_DATA_FORMAT         = 8

        HEADER_NOT_ALLOWED      = 9

        SEPARATOR_NOT_ALLOWED   = 10

        HEADER_TOO_LONG         = 11

        UNKNOWN_DP_ERROR        = 12

        ACCESS_DENIED           = 13

        DP_OUT_OF_MEMORY        = 14

        DISK_FULL               = 15

        DP_TIMEOUT              = 16

        NOT_SUPPORTED_BY_GUI    = 17

        ERROR_NO_GUI            = 18

        others                  = 19.

     

    IF SY-SUBRC <> 0.

      LOOP AT IN_TAB INTO IS_TAB.

    •   Pass the value from the internal table to recroding

        AS01_1-DYNPRO[2]-FIELD[18]-VALIN = IS_TAB-FNAME.

        TCD ( AS01 , AS01_1 ).

        CLEAR IS_TAB.

      ENDLOOP.

    ENDIF.

     

    ENDABAP.

    -


     

     

    PS: If the answer solves your query, reward the points.

     

    Regards

    • Re: Multiple Line items
      parvez ahmed
      Currently Being Moderated

      hi SAP Developer and all,

       

      thanks a lot for your info.

       

      what problem iam actually facing is Iam not writing any code in VA21 script.whatever the code to upload from a test file Iam writing in Chain script.the other scripts va21 and va22 iam calling them in this script.the it_linedata internal table is declared as export parameter in chain script.it_linedata is declared as import parameter in the VA21 script.

       

      VA21_1-DYNPRO[6]-FIELD[28]-VALIN = IT_LINEDATA-V_MATNR.

      TCD ( VA21 , VA21_1 ).

       

      I have tried putting this code in VA21 script .But how to loop this it_linedata at VA21 is the issue while dynamically assigning the values to the Dynpro.

       

      iam getting an error it_linedata is not defined when i run the chain script.

       

      mode        name                      valin

       

      'S'        'BDC_CURSOR'           'RV45A-KWMENG(01)'

      'S'         'RV45A-MABNR(01)'          V_MATNR

      'S'         'RV45A-KWMENG(01)'       V_KWMENG

       

      for one material the above assignment is working fine.but can u please guide me as how to increase the index so as to fill it with required no of materials and quantities as per the test data file.

       

      thanks for your previous response.would appreciate if you could get back to me more on this.

       

      thanks and regards,

       

      parvez

       

       

      Message was edited by: parvez ahmed

       

      • Re: Multiple Line items
        parvez ahmed
        Currently Being Moderated

        hi all,

         

        this is me once again.i have tried as per sapdevelopers answer.But iam unable to resolve my query.iam getting an error

         

        9 MESSAGE Field "VA21_1-DYNPRO[6]-FIELD[28]-VALIN" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement.

         

        pls help regd this matter.

         

        regards,

        parvez

        • Re: Multiple Line items
          Jonathan Maidstone
          Currently Being Moderated

          You may find it easier to record the transaction using the SAPGUI command. The granularity of this command allows you to have separate commands for each screen change. In other words, if you enter the header data and press Enter, the header data is stored in one command, and you can enter the first line item in the next.

           

          Because the commands are separate, you can put a DO loop around the next command to allow you to repeat it. Note that if you do this, you will have to parameterize the IDs of the controls that you address. See here for details. The current line index is contained in the eCATT system variable &LPC. The current line of the table is always &LPC-1 (the loop index begins at 1, line indexes in tables begin at 0).

           

          Hope this helps.

          Regards

          Jon.

           

          Message was edited by: Jonathan Maidstone

           

          Sorry - the link to the documentation didn't work (preview is my friend...)

          <a href="http://help.sap.com/saphelp_nw04/helpdata/en/91/cb79ce29c0de40b91fc04ddb263f1c/content.htm">here</a>

Actions