Loop at internal Table inside Script

Hi
   I am filling a table in a subroutine in a program  and calling it through 'Perform' from my Script,now the main issue is , How to display the table in my script ? 
            I want to loop through an internal table & display its content on my script , but i can't make changes in the calling program by any means.

Hi Ajitabh ,
With PERFORM inside SAPSCRIPT you can only pass individual fields and also get back individual fields .
Check This
http://help.sap.com//saphelp_470/helpdata/EN/d1/802fd3454211d189710000e8322d00/frameset.htm
Only "USING" and CHANGING" options are allowed and that too only symbols available / defined in sapscript can be passed .
Even if you populate an internal table in the program you are calling with "PERFORM" there is no way to pass this internal table back to sapscript , also in SAPSCRIPT there is no way to loop .
If you are sure about the no of lines you are going to populate and all lines have only one column ( only one field ) you can try something like this .
/: PERFORM GET_VALUE IN PROGRAM <ZNAME>
/: USING &VAR1&
/: USING &VAR2&
/: CHANGING &ITAB1&
/: CHANGING &ITAB2&
/: CHANGING &ITAB3&
/: CHANGING &ITAB4&
/: ENDPERFORM
Anothe way is to loop in the main print program and call WRITE_FORM . But I guess your main print program is a SAP std program which you dont want to copy and change.
Cheers.

Similar Messages

  • Fetch the values from internal table inside an internal table (urgent!!)

    data : BEGIN OF PITB2_ZLINFO occurs 0,
             BEGDA LIKE SY-DATUM,
             ENDDA LIKE SY-DATUM,
             PABRJ(4) TYPE N,                       "Payroll Year
             PABRP(2) TYPE N,                       "Pay. Period
             ZL LIKE PC2BF OCCURS 0,
           END OF PITB2_ZLINFO.
    I have a internal table like this,
    How to Fetch the values from internal table inside an internal table.
    Kindly Help me on this..
    Regards,
    Ram.

    Hi,
    Try this....
    Loop at PITB2_ZLINF0.
    Loop at PITB2_ZLINF0-ZL.
    endloop.
    Endloop.
    Thanks...
    Preetham S

  • Making parmanent changes to a internal table inside a user exit

    Hi All,
    I am having a User exit to which I am passing a structure as importing parameter.
    The user exit is not exporting the same structure, but is exporting some other values.
    My problem is that I want to make parmanent changes in the structure I am passing to the user exit.
    Currently what is happening:
    I am passing the structure to the user exit. It has got 6 rows. Inside the user exit I am making some changes to a particular field of all the rows. Till the program control is inside the user exit the changes in the structure are visible. As soon as the control come out of the user exit, the values for the field are switched to teh old values(values before passing to teh user exit).
    My question is, is there any method to make changes to a internal table inside a user exit and these changes are visible outside it when the program control come out of the user exit. (This is when the internal table to which the change is made in not exported by the user exit)

    Hi Dear,
    Your changes done in import parameters will not reflect outside exit. You can only change the values of export parameters...
    If you have very urgent requirement then make changes in SAP''s Standard code.
    For your problem you can write to SAP. In many cases SAP provides the solution.
    Award Points If Useful.

  • Avoiding performance issue due to loop within loop on internal tables

    Hi Experts,
                    I have a requirement where in i want to check whether each of the programs stored in one internal table are called from any of the programs stored in another internal table. In this case i am looping on two internal tables (Loop within a loop) which is causing a major performance issue. Program is running very very slow.
    Can any one advise how to resolve this performance issue so that program runs faster.
    Thanks in advance.
    Regards,
    Chetan.

    Forget the parallel cursur stuff, it is much to complicated for general usage and helps nearly nothing. I will publish a blog in the next days where this is shown in detail.
    Loop on loop is no problem if the inner table is a hashed or sorted table.
    If it must be a standard table, then you must make a bit more effort and faciliate a binary search (read binary search / loop from index exit)
    see here the exact coding Measurements on internal tables: Reads and Loops:
    /people/siegfried.boes/blog/2007/09/12/runtimes-of-reads-and-loops-on-internal-tables
    And don't forget, the other table must not be sorted, the loop reaches anyway every line. The parallel cursor requires both tables to be sorted. The additional sort
    consumes nearly the whole advantage of the parallel cursor compared to the simple but good loop in loop solutions.
    Siegfried

  • Internal table in Script

    Hi All,
    I need to check whether an internal table is having data or not in script.
    Can i use If Not &it_table& is Initial, just like we use in reports, but it is not working.
    Pls advise me how to check whether the internal table is having data or not.
    Thanks,
    Priya

    Hi Priya,
    In SAP script you can not pass all the data to output layout.. Whenever we need to use the the data to be printed on output layout, we first populate that data in a print program.
    First you need to populate your internal table in Print program only.. and to display this data ..
    you need to put a loop on that internal table. pass all the fields into a structure.. and then you can use that structure in script editor. so that your layout can print it one by one..
    You need to code like as below in your print program..
    loop at i_tab.
    i_tab-f1 = w_display-f1.
    i_tab-f2 = w_display-f2.
    i_tab-f3 = w_display-f3.
    * Call the wirte_form
    call function 'WRITE_FORM'
        exporting
          element   = 'ELEMENT'
         window    = 'MAIN'
        exceptions
          element   = 1
          function  = 2
          type      = 3
          unopened  = 4
          unstarted = 5
          window    = 6
          others    = 7.
    endloop.
    Now in editor you can put like that:
    */E ELEMENT*
    *PF &w_display-f1&,, &w_display-f2&,, &W_display-f3&*

  • Error "Screen output are too small" when looping through internal table!

    Hello All:
         I have a huge internal table with some 79000 records and while looping through them and doing some other processing inside the loop, I am getting an error "Screen output are too small"! Could someone please help mw how to fix this issue? I can send the all the code if anyone wants to look at the code. Thanks in advance and rewards are assured.
    Mithun

    Hi,
    Check this
    new-page print off.
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
    EXPORTING
    destination = v_dest
    IMPORTING
    out_parameters = params
    valid = valid.
    * params-linct = '58'.
    * params-linsz = '170'.
    * params-paart = 'X_58_170'.
    * params-prtxt = v_spool_text.
    * params-primm = 'X'.
    * params-prrel = 'X'.
    NEW-PAGE PRINT ON PARAMETERS params NO DIALOG.
    After the call fm GET_PRINT_PARAMETERS params internal table contains all the values for generating spool.
    aRs

  • Program times out while looping at internal table with huge records - Needs fine tuning suggestions

    Hi,
    I am trying to execute a report. It times out while looping at vbap internal table. This internal table has 140000  records and does the validation within this loop and geenrates data for the output. Due to this huge volume, the program times out when executed foreground.
    There are no nested loops, so I cannot apply 'Parallel Cursor' here.
    Is there any way I can fine tune the program so that it doesn't timeout? Is it possible to apply 'Parallel Processing' . If yes, how?
    Thanks,
    Pavan

    Hi Pavan ,
                  ->sort your internal table by all primary key for vbap.
                  ->Read a Record from the table (use your condition here)
                  ->if record satisfys your where condition ,get that record index .
                  ->loop the table from the index (without condition) .
                  its like parallel cursor only but for single loop .;-)
                  ->use field symbols ,wherever possible .
               if still dump is coming ,contact your basis team .
    regards,
    Krishna.

  • Looping at internal table is taking lots of time

    Hi,
    I have two internal tables IT_1 and IT_2. My requirement is as below:-
    For record in table IT_1 if no record is found in table IT_2 then appned to the third table IT_3.
    I am using the below code for the same.
      LOOP AT tbl_articles INTO tbl_articles.
        READ TABLE tbl_prix_art WITH KEY matnr = tbl_articles-matnr.
        IF sy-subrc <> 0.
          MOVE tbl_articles TO tbl_articles_2.
          APPEND tbl_articles_2.
        ENDIF.
        CLEAR : tbl_articles, tbl_articles_2.
      ENDLOOP.
    But is taking huge amount of time due to larger number of records in tbl_articles .
    Is there any other way through which i can get the same functionality.
    Regards
    Sachin

    Sachin,
    Some food for thought.
    Irrespective of how you define the table it has to go through the n number of rows in tbl_articles because that is the basic functioanlity.
    I think your READ TABLE is what is delaying your process here. So try a Binary Search as below.
    Line 1 of change --> SORT tbl_prix_art asc ASCENDING matnr. 
    LOOP AT tbl_articles INTO tbl_articles.
    Line 2 of change --> READ TABLE tbl_prix_art BINARY SEARCH  WITH KEY matnr = tbl_articles-matnr.
    IF sy-subrc 0.
    MOVE tbl_articles TO tbl_articles_2.
    APPEND tbl_articles_2.
    ENDIF.
    CLEAR : tbl_articles, tbl_articles_2.
    ENDLOOP.
    I am confident this will solve your long run times.
    Thanks
    Mani

  • SAP QUERY LOOPS AND INTERNAL TABLE

    Hi All, I have a query which i have made. It runs from Table EKPO which has PO details and what I want to do is now via ABAP Code pull through the total of goods receipt for the PO and Line Item into a field. Sounds Easy enough..Problem now,
    The table which contains the GR data is EKBE which agains a PO and Line Item can have many 101 movements and 102 movements so what I want is an ABAP Statent to basically sum up the total of 101 for the PO & LINE ITEMS and then minus this from the total of 102 for the PO & LINE ITEMS and post the result in to this new field I have created.
    I am pretty decent with ABAP Code in Querys I.e Select statements etc but from what I can see i need to create an internal table and do a loop and collect statement but I keep on failing due to not enough knowledge. Please can some one help me with this and provide me with the code and explanation as i would like to understand,
    POINTS WILL BE REWARDED
    Thanks
    Kind Regards
    Adeel Sarwar

    Hi,
    This is the full code i have entered but its not working. Any help would be appreciated. If you could rectify the code and internal tables that would be great.
    Thanks
    TABLES: EKBE.
    DATA: PurO LIKE EKPO-EBELN,
          POLI LIKE EKPO-EBELP.
    *New Table and Vars defined
    DATA:   BEGIN OF IT_EKBE,
              IT_EKBE LIKE EKBE,
            END OF IT_EKBE.
    DATA:  BEGIN OF IT_SUM OCCURS 0,
              EBELN TYPE EBELN,
              EBELP TYPE EBELP,
              DMBTR TYPE DMBTR,
              MENGE TYPE MENGE,
          END OF IT_SUM.
    CLEAR: QTYD.
    MOVE: EKPO-EBELN TO PurO,
          EKPO-EBELP TO POLI.
    SELECT * FROM EKBE INTO IT_EKBE
        WHERE EBELN = PurO
        AND   EBELP = POLI
        AND   BEWTP = 'E'
    LOOP AT IT_EKBE.
      MOVE CORRESPOING IT_EKBE TO IT_SUM.
      IF IT_EKBE-BWART = '102'.
        IT_SUM-DMBTR = IT_SUM-DMBTR * -1.
        IT_SUM-MENGE = IT_SUM-MENGE * -1.
      ENIDF.
      COLLECT IT_SUM.
      CLEAR IT_SUM.
    ENDLOOP.
    ENDSELECT.
    If sy-subrc = 0.
      QTYD = IT_SUM.
    ELSE.
      QTYD = 0.
    ENDIF.

  • Smartform loop into internal table problem

    hello experts,
    i am doing an example given in **************** regarding smartforms. I am getting problem which doing the smartforms . please help me.
    http://****************/Tutorials/Smartforms/SFMain.htm
    in that i am doing the program
    Working with loop.
    I have done exactly as the screen shots in the program.
    Now in the main window i created a loop.
    in that loop i am not getting the option internal table.
    But it is showing as operand . It is in the data tab of the loop.
    I searched the all the tabs in the loop but did not find the option  internal table.
    so then i ticked the operand and i did as speified in the screen shots.
    it_tab into fs_tab
    Then i created a text and then placed &fs_tab-vbeln& etc.
    then i executed the smartform now in the output i am not getting the sales order number , item etc.
    The output is showing like
    &fs_tab-vbeln&     &fs_tab-posnr&   etc.
    please guide me how to get the internal table option in  the loop. And also tell me how to rectify this problem

    thanks for all the replies.
    I will give all  at the time of closing my thread.
    Hi Sravanthi -> in loop node i am not getting the internal table insted of that i am getting operand in the data tab.
    This is my main problem.I dont why operand is comming there.
    my version is 4.7e
    Hi Karthik and swati -> i simply hard coded the statements in the text as shown in the example.
    Now i will try with the add field.
    But please tell me why i am not getting internal table option in loop.

  • How to transfer data of RFC into Internal Table inside a WD4A program?

    Hi Experts,
    I have created WD4A program. This program calls RFC. The output of RFC has to populate  a UI table. THe different cells of the table should have different color based on data.
    I have gone through following link:
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/707fb792-c181-2d10-61bd-ce15d58b5cf1
    The above link fetches data from directly from table. Then it passes the data into internal table.
    If I am using RFC, then how I can insert data of RFC into a internal table in WD4A program (se80 In drop down Web Dynpro Comp / Intf)
    My motto is to have table ouput whose different cells should have different color based on data.
    Please help.
    Regards,
    Gary
    Edited by: Jason Lax on Dec 28, 2011 2:52 PM (Fixed broken link)

    Hi Experts,
    I have resolved the issue. I have created WD4A program. This WD4A program calls the RFC.
    The RFC has a structure as export parameters called 'RESULT_FINAL'. I have altered the associated type of this table export parameter. I added Component 'Color' of component type 'WDUI_TABLE_CELL_DESIGN'.
    In the RFC I have added some code. The code is as below:
    loop  at it_t1.
          select pernr from pa0000 into table it_t2 where  pernr = it_t1-pernr  and stat2 ='3'
          and begda <= sy-datum AND endda >= sy-datum.
          if sy-subrc = 0.
            result_final-org_unit = result_objec-objid.
            result_final-pernr = it_t1-pernr.
            result_final-name = it_t1-name.
            result_final-color = '02'.       append result_final.
          endif.
        endloop.
    The line   result_final-color = '02'.   
    code returns Color.
    In the WD4A program, I have changed the Cell Design property of selected table coloumn to Color.
    This resolved the issue.
    Thanks every one for the reply.
    I have added above information for other SDN users.
    I am closing this thread,
    Regards,
    Gary

  • Loop at internal table and get the right line

    Hi,
    I've a table like this sorted by material1 and date.
    Material 1...Date..........Material 2...Stock 
    A1.............01/01/08........A2..........100
    A1.............01/01/07........A2..........150
    B1.............01/05/08........B1..........50
    B1.............01/03/07........B2..........100
    B1.............01/02/07........B3..........75
    I need to put in another table only the line for material1 which has the highest date.
    For this example, line 1 and 3 should be selected.
    Can anyone tell me how to code this??
    Thanks.

    Hi tarick,
    Try this,,
    Create another internal table  itab2 of type itab1 and copy all entries of itab1 to itab2.
    itab2[] = itab1[].
    Now delete adjacent duplicates from itab2 comparing material1.
    DELETE ADJACENT DUPLICATES FROM itab2 comparing material1.
    Effect
    Deletes adjacent duplicate entries from the internal table itab2. If there are n duplicate entries in succession, the first entry is retained, and the following n-1 entries are deleted.
    Reward Points if Helpful.
    Regards,
    Sachin M M

  • How to save Internal table inside Personnel Change Request after JSPcode ??

    HI ,
         I have built up Som Org management Data while running PCR . But when it goes to JSP for form display
    and comes back to SAP. The internal table that I have saved in SAP MEMORY / ABAP MEMORY is getting washed off..
    I m building the table in the INIT method of the BADI ( qisr1) .
    Can any body suggest a way for saving the DATA when control is back from JSP.
    is it posible thr saving in som class private data ??

    SAP and ABAP Memory belong to a user session, in a new session you wont have access to the ABAP/SAP Memory of another session. Seems like you are using a stateless JSP.
    Instead you could use the Shared Memory, check this link: http://help.sap.com/saphelp_nw04s/helpdata/en/14/dafc3e9d3b6927e10000000a114084/frameset.htm or you use a Server-Side cookie, http://help.sap.com/saphelp_nw70/helpdata/EN/bd/4cd23a09313b37e10000000a11405a/frameset.htm
    regards,
    Markus

  • Looping at internal table

    Hi, I work on SAP BW and need guidance on the functionality from the below code:
    l_s_datapak_line[] = datapak[].
        l_s_datapak[] = datapak[].
        sort l_s_datapak_line by pernr endda descending.
    loop at l_s_datapak.
       read table l_s_datapak_line with key pernr = l_s_datapak-pernr
       endda = '99991231'.
       if sy-subrc = 0.
    pernr = l_s_datapak_line-pernr.
            curr_compcode = l_s_datapak_line-bukrs.
            curr_job = l_s_datapak_line-stell.
            curr_mastcctr = l_s_datapak_line-kostl.
            curr_orgunit = l_s_datapak_line-orgeh.
            curr_persarea = l_s_datapak_line-werks.
            curr_perssubarea = l_s_datapak_line-BTRTL.
            curr_position = l_s_datapak_line-plans.
            curr_chief = l_s_datapak_line-zzchiefpernr.
            curr_supervisor = l_s_datapak_line-zzsupervisor.
            modify i_curr index i_index.
           exit.
          endif.
        endloop.
    In the above code, I want the loop to run only once for each pernr. If there are 10 records in l_s_datapak with pernr = 100, then the loop would run 100 times although there would be only one record in l_s_datapak_line with endda = '99991231'. I want the loop to run only once , assign the values and then l_s_datapak-pernr should become 101. How do I do it?
    Any help is highly appreciated and thanks for the help in advance.

    Hi,
    Use Control Break statements i.e. AT NEW....ENDAT as shown below.
    l_s_datapak_line[] = datapak[].
    l_s_datapak[] = datapak[].
    sort l_s_datapak_line by pernr endda descending.
    loop at l_s_datapak.
    <b>AT NEW pernr.</b>
    read table l_s_datapak_line with key pernr = l_s_datapak-pernr
    endda = '99991231'.
    if sy-subrc = 0.
    pernr = l_s_datapak_line-pernr.
    curr_compcode = l_s_datapak_line-bukrs.
    curr_job = l_s_datapak_line-stell.
    curr_mastcctr = l_s_datapak_line-kostl.
    curr_orgunit = l_s_datapak_line-orgeh.
    curr_persarea = l_s_datapak_line-werks.
    curr_perssubarea = l_s_datapak_line-BTRTL.
    curr_position = l_s_datapak_line-plans.
    curr_chief = l_s_datapak_line-zzchiefpernr.
    curr_supervisor = l_s_datapak_line-zzsupervisor.
    modify i_curr index i_index.
    exit.
    endif.
    <b>ENDAT.</b>
    endloop.
    Reward points if the answer is helpful.
    Regards,
    Mukul

  • Loop at internal table

    Hi. I am fairly new to ABAP. I have a small doubt which requires your help. I wan to know if the following statement is correct.
    loop at g_t_data where matnr in so_matnr.
    so_matnr is a select option for mara-matnr.
    I want to know if it is correct to use a select option after the where clause. I tried using it, and I didnt get any syntax error. I want to know if it is a right programming practice to do so.

    As Suresh had mentioned you can use it.
    For ABAP related questions , post them in ABAP forum for better response.
    ABAP Development
    Regards
    Raja

Maybe you are looking for

  • Jenkins can not connect Visual Studio Online(not git repository)

    I have seen some techinical document and tried some scenario. 1. Alternative Authentication on my profile     Usename(primary) is my company email address.     Username(secondary) is none. 2. set jenkins setup for TFS plug-in      Tema Foundation

  • Enabling and disabling the button in the multi record block

    hi all, i am using Forms [32 Bit] Version 6.0.8.24.1 (Production) Oracle Database 10g Release 10.2.0.1.0 - Production i have a multi record block each block contains a button(button is to approve the record in terms of changing the status) i have the

  • Business Logic in BC4J. Guide please

    I have a question regarding BC4J I am currently reading the white paper on this : http://www.oracle.com/technology/products/jdev/info/techwp20/wp.html#introduction Find figure 8(View Objects Cooperate with Related Entity Objects...' and see the 2nd p

  • Error message 131:4

    Hello, I started up PS CS5.1 and got this error message that mentioned a configuration problem.  Does anybody know what this is?

  • Firefox 7 + youtube

    This keeps happening to me: Can't go forward or pause the video and this happens, can anybody help me? I know there's a lot of people with problems with flash, I tried downgrading flash, unninstall and start firefox in safe mode, keeps happening. Unn