Logic in internal table -- Urgent

Hi All,
I have an internal table idoc_data of structure
      DOCNUM  SEGNUM  SEGNAM       
      3164     00001  E1STZUM -
1st idoc
      3164     00002  E1MASTM
      3164     00003  E1MARAM
      3164     00004  E1MAKTM
      3164     00005  E1STPOM -
end of 1st idoc
      3164     00006  E1STZUM  -
2nd idoc
      3164     00007  E1MASTM
      3164     00008  E1MARAM
      3164     00009  E1STPOM -
end of 2nd idoc
      3164     00010  E1STZUM  -
3rd idoc
      3164     00011  E1MASTM
      3164     00012  E1MARAM
      3164     00013  E1STPOM  -
end of 3rd idoc
      and so on .........
"Pls note that the idocs are collected into a single idoc having same DOCNUM 3164".
I have to write a logic like this.
Loop at idoc_data.
Move the first idoc record starting from E1STZUM -
1st idoc till E1STPOM----end of 1st idoc into a temporary internal table and call master_idoc_distribute to send an idoc out.
Move the second idoc record starting from E1STZUM  -
2nd idoc till E1STPOM -
end of 2nd idoc into the temporary internal table and call master_idoc_distribute to send an idoc out.
Move the third idoc like the same and so on........for the whole idocs. 
There could be even more than 5000 idocs in the same structure having same idoc number.
Any help in writing the logic is really appreciated. Pls send me the whole code itself. It is an urgent reqmt. So pls do the needful.....
Thanks
Ricky

Will explain one more time.
Internal table structure
DOCNUM SEGNUM SEGNAM
3164 00001 E1STZUM -
1st idoc
3164 00002 E1MASTM
3164 00003 E1MARAM
3164 00004 E1MAKTM
3164 00005 E1STPOM
3164 00006 Z1MARZ -
end of 1st idoc (this could be more than one )
3164 00007 E1STZUM -
2nd idoc
3164 00008 E1MASTM
3164 00009 E1MARAM
3164 00010 E1STPOM
3164 00011 Z1MARZ -
end of 2nd idoc (this could be more than one)
3164 00010 E1STZUM -
start of 3rd idoc
3164 00011 E1MASTM
3164 00012 E1MARAM
3164 00013 E1STPOM
3164 00014 Z1MARZ     -
end of 3rd idoc (this could be more than one)
and so on.........
"Pls note that the idocs are collected into a single idoc having same DOCNUM 3164".
I have to write a logic like this.
Loop at idoc_data.
Move the first idoc record starting from E1STZUM -
1st idoc till Z1MARZ----end of 1st idoc into a temporary internal table and call '' FM master_idoc_distribute'' to send an idoc out.
Move the second idoc record starting from E1STZUM -
2nd idoc till Z1MARZ -
end of 2nd idoc into the temporary internal table and call FM "master_idoc_distribute" to send an idoc out.
Move the third idoc like the same and so on........for the whole idocs.
There could be even more than 5000 idocs in the same structure having same idoc number.
Any help in writing the logic is really appreciated. Pls send me the whole code itself. It is an urgent reqmt. So pls do the needful.....
Thanks

Similar Messages

  • Logic inside internal table

    hello all,
    i have a requirement like this,
    there are two select statements like below
    select * from IFLO appending corresponding fields of table it_itab_33kv
    where begru eq '006F' and fltyp eq '6'.
    select * from IFLO appending corresponding fields of table it_itab_33kv
    where begru eq '004F' and fltyp eq '4'.
    i wanted to do some thing like this in my ALV report
    serno      cost center     cost center name    no:of 33kv substations       no:of 11kv feeders
    1              0402120401       xxxxx                         2                                          1
    2              0402120301       xxxxx                         1                                          3
    3              0402120201       xxxxx                         3                                          2
    cost center wise i need to aggregate this,
    how do i write my logic in internal table....
    suggest me some ways....
    thankq

    Hi,
    in the final alv grid u want to display  first u sort the cost center and if you want to add the 33 kv and 11 kv feeder.use the code
    data: l_grid type ref to cl_salv_table,
           lr_functions type ref to cl_salv_functions_list.
    CONSTANTS: gc_true  TYPE sap_bool VALUE 'X'.
    sortlt_final ascending costcenter.
    loop at lt_final into wa_final.
    collect wa_final into lt_final.
    endloop.
    CALL METHOD cl_salv_table=>factory
       IMPORTING
         r_salv_table = l_grid
       CHANGING
         t_table      = lt_final.
    lr_functions = l_grid->get_functions( ).
    lr_functions->set_all( gc_true ).
    l_grid->display( ).
    hope it helps...do reward so

  • Need a logic for Internal table processing

    Hi,
    I have a requirement...an internal table contains three fields material no, bin no, and Quantity
    Mat. No    |         Bin No        |              Quantity
    a              |              x1         |                   10
    a              |              x1         |                   10
    a              |              x2         |                   20
    b              |              x3         |                   10 
    c              |              x3         |                   20
    c              |              x4         |                   30
    c              |              x4         |                   40
    In this I need to append the records to new internal table say itab1 where multiple entries exist for some material no like mat no 'a' and 'c'  and
    if the material no. exist only once in the table, it has to be moved to another new internal table say itab2.
    Pls suggest some logic that does not have performance issues.
    Thanks in advance
    Saravana

    Hi there,
    a solution in brief...
    data: wa_itab1_a like itab1,
             wa_itab2_b like itab1,
             lv_tabix       type sytabix.
    sort itab1 by matnr.
    loop at itab1.
      wa_itab1_a = itab1.
      at new matnr.
        lv_tabix = sy-tabix + 1.
        clear wa_itab2_b.
        READ TABLE itab1 into wa_itab2_b
                            INDEX lv_tabix.
        if wa_itab2_b-matnr ne wa_itab1_a-matnr.
          append wa_itab1_a to itab2.
          delete itab1 where matnr = wa_itab1_a-matnr.
        endif.
      endat.
    endloop.
    Regards
    George Zervas
    Edited by: gzervas on Oct 20, 2010 12:08 PM

  • Need logic in Internal table processing

    Hi all,
    I have requirement like this.
    i cretaed  three internal tables
    1) first Internal table can store total uploaded data from flat file..means line by line( Here each line is one record)
    2) Second internal can store all fields which are fetched based on table which is given on selction screen.
    3)now i cretaed one internal table with one variable
    4) i used spilt statement on first internal table ( which store all flat file recrds) into third internal table.
    so , my third internal table has first records values of first internal table in one column.
    Now my probelm...i need to populate bapi structre tables with values of third internal table based on field names of second internal table. i am not able to do logic.
    Is there any pointers to know soultion
    Note:we know which fields values from flat values  needs to populate Bapi structure table..
    Thanks in advance,
    regards,
    JBR

    check this program may be u will get the logic
    *& Report  ZBAPI_MATERIAL_SAVEDATA
    *& PURPOSE : THIS REPORT USES BAPI MATERIAL SAVE DATA TO UPDATE AND CREATE
    *&           THE MATERIAL
    REPORT  ZBAPI_MATERIAL_SAVEDATA NO STANDARD PAGE HEADING MESSAGE-ID (ZHNC).
    TYPES:BEGIN OF TY_MAT,
           MATERIAL(4),
           IND_SECTOR(1),
           MATL_TYPE(4),
           MATL_GROUP(9),
           BASE_UOM(3),
           BASE_UOM_ISO(3),
           PLANT(4),
           DEL_FLAG(1),
           PUR_GROUP(3),
           BASE_QTY(13),
           STGE_LOC(4),
           MRP_IND(1),
           SALES_ORG(4),
           DISTR_CHAN(2),
           DEL_FLAG1(1),
           MIN_ORDER(13),
           LANGU(2),
          MATL_DESC(40),
       END OF TY_MAT.
    DATA: IT_DATA TYPE TABLE OF TY_MAT,
          WA_DATA LIKE LINE  OF IT_DATA.
    *decalraing flag
    data: v_flag value ''.
    *DECLARING WORK AREAs  TO BE PASSED TO THE FUNCTION MODULE.
    DATA: BAPI_HEAD LIKE BAPIMATHEAD,
          BAPI_CLIENTDATA LIKE BAPI_MARA,
          BAPI_CLIENTDATAX LIKE BAPI_MARAX,
          BAPI_PLANTDATA LIKE BAPI_MARC,
          BAPI_PLANTDATAX LIKE  BAPI_MARCX,
          BAPI_STORAGELOCATIONDATA LIKE BAPI_MARD,
          BAPI_STORAGELOCATIONDATAX LIKE BAPI_MARDX,
          BAPI_SALESDATA LIKE BAPI_MVKE,
          BAPI_SALESDATAX LIKE BAPI_MVKEX,
          BAPI_MAKT LIKE BAPI_MAKT,
          BAPI_RETURN LIKE BAPIRET2.
    *INTERNAL TABLE TO HOLD THE MATERIAL DESCRIPTION
    DATA: BEGIN OF IT_MAKT OCCURS 0.
    INCLUDE STRUCTURE BAPI_MAKT.
    DATA END OF IT_MAKT.
    DATA:BEGIN OF IT_RET OCCURS 0.
    INCLUDE STRUCTURE BAPIRET2.
    DATA END OF IT_RET.
    *INTERNAL TABLE TO HOLD HEADER DATA
    DATA: IT_EXCEL TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
    *SELECTION-SCREEN ELEMENTS
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETER: FNAME TYPE RLGRAP-FILENAME OBLIGATORY DEFAULT 'C:\Documents and Settings\Administrator\Desktop\MATMAS.XLS' .
    PARAMETERS: P_BEGCOL TYPE I DEFAULT 1 NO-DISPLAY,
                P_BEGROW TYPE I DEFAULT 1 NO-DISPLAY,
                P_ENDCOL TYPE I DEFAULT 100 NO-DISPLAY,
                P_ENDROW TYPE I DEFAULT 32000 NO-DISPLAY.
    SELECTION-SCREEN END OF BLOCK B1.
    *DECLARATION OF EXCELAL TABLE
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR FNAME.
    PERFORM F_GET_FILE USING FNAME.
    START-OF-SELECTION.
    PERFORM F_XLS_ITAB USING FNAME
                       CHANGING IT_EXCEL.
    PERFORM F_MOVE_DATA.
    perform F_GET_DATA.
    *&      Form  F_GET_FILE
          text
         -->P_FNAME  text
         <--P_SY_SUBRC  text
    FORM F_GET_FILE  USING    P_FNAME LIKE FNAME.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
       PROGRAM_NAME        = SYST-REPID
       DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = ' '
      STATIC              = ' '
      MASK                = ' '
      CHANGING
        FILE_NAME           = P_FNAME
    EXCEPTIONS
      MASK_TOO_LONG       = 1
      OTHERS              = 2
    IF SY-SUBRC <> 0.
    MESSAGE E006(ZHNC).
    ENDIF.
    ENDFORM.                    " F_GET_FILE
    *&      Form  F_XLS_ITAB
          text
         -->P_FNAME  text
         <--P_IT_EXCEL  text
    FORM F_XLS_ITAB  USING    P_FNAME
                     CHANGING P_IT_EXCEL.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        FILENAME                      = FNAME
        I_BEGIN_COL                   = P_BEGCOL
        I_BEGIN_ROW                   = P_BEGROW
        I_END_COL                     = P_ENDCOL
        I_END_ROW                     = P_ENDROW
      TABLES
        INTERN                        = IT_EXCEL
    EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 2
       OTHERS                        = 3
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.                    " F_XLS_ITAB
    *&      Form  F_MOVE_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM F_MOVE_DATA .
    DATA : LV_INDEX TYPE I.
    FIELD-SYMBOLS <FS>.
    *--- Sorting the internal table
    SORT IT_EXCEL BY ROW COL.
    CLEAR IT_EXCEL.
    LOOP AT IT_EXCEL.
    MOVE IT_EXCEL-COL TO LV_INDEX.
    *--- Assigning the each record to an internal table row
    ASSIGN COMPONENT LV_INDEX OF STRUCTURE WA_DATA TO <FS>.
    *--- Asigning the field value to a field symbol
    MOVE IT_EXCEL-VALUE TO <FS>.
    AT END OF ROW.
    APPEND WA_DATA TO IT_DATA.
    CLEAR WA_DATA.
    ENDAT.
    ENDLOOP.
    ENDFORM.                    " F_MOVE_DATA
    *&      Form  F_GET_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM F_GET_DATA .
    LOOP AT IT_DATA INTO WA_DATA.
    MOVE-CORRESPONDING WA_DATA  TO  BAPI_HEAD.
    BAPI_HEAD-BASIC_VIEW ='X'.
    BAPI_HEAD-SALES_VIEW ='X'.
    BAPI_HEAD-PURCHASE_VIEW ='X'.
    BAPI_HEAD-STORAGE_VIEW ='X'.
    MOVE-CORRESPONDING WA_DATA TO BAPI_CLIENTDATA.
    BAPI_CLIENTDATAX-MATL_GROUP = 'X'.
    BAPI_CLIENTDATAX-BASE_UOM = 'X'.
    BAPI_CLIENTDATAX-BASE_UOM_ISO = 'X'.
    MOVE-CORRESPONDING WA_DATA TO BAPI_PLANTDATA.
    BAPI_PLANTDATAX-PLANT = BAPI_PLANTDATA-PLANT.
    BAPI_PLANTDATAX-DEL_FLAG = 'X'.
    BAPI_PLANTDATAX-PUR_GROUP = 'X'.
    BAPI_PLANTDATAX-BASE_QTY = 'X'.
    MOVE-CORRESPONDING WA_DATA TO BAPI_STORAGELOCATIONDATA.
    BAPI_STORAGELOCATIONDATA-PLANT = BAPI_PLANTDATA-PLANT.
    BAPI_STORAGELOCATIONDATAX-PLANT = BAPI_STORAGELOCATIONDATA-PLANT.
    BAPI_STORAGELOCATIONDATAX-STGE_LOC = BAPI_STORAGELOCATIONDATA-STGE_LOC.
    BAPI_STORAGELOCATIONDATAX-MRP_IND = 'X'.
    MOVE-CORRESPONDING WA_DATA TO BAPI_SALESDATA.
    BAPI_SALESDATAX-SALES_ORG = BAPI_SALESDATA-SALES_ORG.
    BAPI_SALESDATAX-DISTR_CHAN = BAPI_SALESDATA-DISTR_CHAN.
    BAPI_SALESDATAX-DEL_FLAG = BAPI_SALESDATA-DEL_FLAG.
    BAPI_SALESDATAX-MIN_ORDER = 'X'.
    REFRESH IT_MAKT.
    IT_MAKT-LANGU = WA_DATA-LANGU.
    IT_MAKT-MATL_DESC = WA_DATA-MATL_DESC.
    APPEND IT_MAKT.
    CLEAR IT_RET.
    REFRESH IT_RET.
    PERFORM F_CALL_BAPI.
    READ TABLE IT_RET WITH KEY TYPE = 'S'.
    IF SY-SUBRC EQ 0.
    PERFORM F_BAPI_COMMIT.
    WRITE:/ 'MATERIAL CREATED OR UPDATED SUCESSFULLY WITH MATERIAL NO',WA_DATA-MATERIAL.
    ELSE.
    MESSAGE E000(ZHNC) WITH 'ERROR IN CREATING THE MATERIAL'.
    *WRITE: / 'ERROR IN CREATIN MATERIAL',IT_RET-MESSAGE.
    *PERFORM F_DOWNLOAD.
    ENDIF.
    *ENDIF.
    ENDLOOP.
    ENDFORM.                    " F_GET_DATA
    *&      Form  F_CALL_BAPI
          text
    -->  p1        text
    <--  p2        text
    FORM F_CALL_BAPI .
    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
      EXPORTING
        HEADDATA                   = BAPI_HEAD
       CLIENTDATA                 =  BAPI_CLIENTDATA
       CLIENTDATAX                =  BAPI_CLIENTDATAX
       PLANTDATA                  =  BAPI_PLANTDATA
       PLANTDATAX                 =  BAPI_PLANTDATAX
       STORAGELOCATIONDATA        =  BAPI_STORAGELOCATIONDATA
       STORAGELOCATIONDATAX       =  BAPI_STORAGELOCATIONDATAX
       SALESDATA                  =  BAPI_SALESDATA
       SALESDATAX                 =  BAPI_SALESDATAX
    IMPORTING
       RETURN                     =  IT_RET
    TABLES
       MATERIALDESCRIPTION        = IT_MAKT
      UNITSOFMEASURE             =
      UNITSOFMEASUREX            =
      INTERNATIONALARTNOS        =
      MATERIALLONGTEXT           =
      TAXCLASSIFICATIONS         =
      RETURNMESSAGES             =
      PRTDATA                    =
      PRTDATAX                   =
      EXTENSIONIN                =
      EXTENSIONINX               =
    APPEND IT_RET.
    ENDFORM.                    " F_CALL_BAPI
    *&      Form  F_BAPI_COMMIT
          text
    -->  p1        text
    <--  p2        text
    FORM F_BAPI_COMMIT .
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      WAIT         =
    IMPORTING
      RETURN        =
    ENDFORM.                    " F_BAPI_COMMIT

  • Joining Two Internal Tables - ( Urgent )

    Could anybody please give me the whole code for joining two internal tables
    and putting the data in a third internal table. Please, very urgent.
                                                                                    Regards,
                                                                                    SAURAV

    Hi,
      Refer this code
    *&      Form  SUB_READ_VBRK
          text
    FORM sub_read_vbrk.
      SELECT vbeln
             rplnr
             bukrs
             FROM vbrk
             INTO TABLE it_vbrk
             WHERE vbeln IN s_vbeln
             AND   rplnr NE ' '.
      IF sy-subrc EQ 0.
        SORT it_vbrk BY rplnr.
      ENDIF.
    ENDFORM.                    " SUB_READ_VBRK
    *&      Form  SUB_READ_FPLTC
          text
    FORM sub_read_fpltc.
      IF NOT it_vbrk[] IS INITIAL.
        SELECT fplnr
               fpltr
               ccnum
               FROM fpltc
               INTO TABLE it_fpltc
               FOR ALL ENTRIES IN it_vbrk
               WHERE fplnr EQ it_vbrk-rplnr
               AND   ccins EQ 'GIFC'.
        IF sy-subrc EQ 0.
          SORT it_fpltc BY fplnr.
        ENDIF.
      ENDIF.
    ENDFORM.                    " SUB_READ_FPLTC
    *&      Form  SUB_COLLECT_DATA
          text
    FORM sub_collect_data.
    *--Local variables
      DATA : lv_count(3) TYPE c.
      IF NOT it_fpltc[] IS INITIAL.
        LOOP AT it_fpltc INTO wa_fpltc.
          lv_count = wa_fpltc-fpltr+3(3).
          wa_final-ccnum = wa_fpltc-ccnum.
          wa_final-rfzei = lv_count.
          CLEAR : wa_vbrk.
          READ TABLE it_vbrk INTO wa_vbrk WITH KEY rplnr = wa_fpltc-fplnr
                                                   BINARY SEARCH.
          IF sy-subrc EQ 0.
            wa_final-vbeln = wa_vbrk-vbeln.
            wa_final-bukrs = wa_vbrk-bukrs.
          ENDIF.
          APPEND wa_final TO it_final.
          CLEAR : wa_vbrk,
                  wa_fpltc,
                  lv_count.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " SUB_COLLECT_DATA
    Regards,
    prashant

  • 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

  • Inserting a record in an internal table - Urgent

    Hi Friends,
    I have a requirement where in I have 2 internal tables say itab1 and itab2.Itab1 has 10 records and itab2 has one record initially.
    Now I have to move the records of itab1 into itab2.
    My question is if some conditions satisfy,then I need to append the records of itab1 after the single record in itab2.In some other cases I need to insert the records of itab1 before
    the single record in itab2.
    What is the syntax to attach the records before the record as append statement always attaches the record after the existing record.
    Your help is highly appreciated.
    Regards,
    Vishnu.

    You can use insert itab index idx .
    Alternative 2
    ... itab INDEX idx
    Effect
    This variant can only be used for standard tables and sorted tables. Each line line_spec to be inserted into the line before the table index idx and the table index of the following lines is increased by one. A data object of the type i is expected for idx.
    If idx contains a value equal to the number of the existing table lines plus one, the new line is appended as the last line in the internal table. If idx contains a greater value, no line is inserted and sy-subrc is set to 4.
    An exception that cannot be handled is raised when:
    idx contains a value less than or equal to 0
    A line to be inserted would cause a duplicate entry in tables with a unique table key
    A line to be inserted would disrupt the sort order of sorted tables
    Within a LOOP loop, you can omit the addition INDEX. Each line to be inserted is inserted before the current table line of the LOOP loop. However, if the current line is deleted in the same loop pass, the response is undefined.
    read help on this .
    reward if helpful

  • Summarizing entries of the Internal table--Urgent..plz help

    Hi All!!
    I have an internal table containing fields f1, f2 ,f3 ..f8.
    I want to summarize the entries based on three fields of table f1,f2 and f3.These fields are numeric fields.The other fields have numeric and non numeric fields.One of the field f4 is quantity field which needs to summed.
    For example the contents:
    1 2 3 4 A 5 6 7
    1 2 3 4 A 5 6 7
    1 2 3 4 B 5 6 7
    3 4 5 5 D 5 6 7
    3 4 5 6 D 5 6 7
    will be summarized as
    1 2 3 8 A 5 6 7
    1 2 3 4 B 5 6 7
    3 4 5 11 D 5 6 7
    4th field is quantity field.It is assumed that if the first 3 fields are same all others numeric field will be same.Non numeric may be different.
    Please help in this regard..
    Thanks in advance..
    Prabhas.

    Hi Prabhas,
    Decalre your internal table of type HASHED. < See F1 to declare such a table>. with key fields as all the character fields.
    Then when you are making the entry in your table Use Collect statement.
    like Collect itab.
    This should give you the required results.
    Use table declaration as Hashed Table only.
    Use F1 to get details, In case you need code I can give the same as well.
    Hope this helps.
    Happly Learning!
    Regards,
    Lalit

  • Logic for internal table

    Hi,
    I have an internal table with the following structure.
    PO Number     PO Line Number     Quantity     ETA
    PO_1     001     10     10 Aug 2009
    PO_1     002     12     11 Aug 2009
    PO_2     001     5     10 Aug 2009
    PO_1     001     13     10 Aug 2009
    PO_1     001     7     11 Aug 2009
    Now I want to sum up quantity based on ETA dates so that the structure will look like as below:
    PO Number     PO Line Number     Quantity     ETA
    PO_1     001     23     10 Aug 2009
    PO_1     001     7     11 Aug 2009
    PO_1     002     12     11 Aug 2009
    PO_2     001     5     10 Aug 2009
    Collect statement will not work as the checking is on date but not  on po no and line item.
    Regards,
    Abhi...

    Use SUM statement for adding the quantity fields.
    Sample code :
    LOOP AT T INTO WA_T.
    WA_N = WA_T
        SUM.
    WA_N-QUANTITY = WA_T-QUANTITY.
    APPEND WA_N TO ITAB_N.
    ENDLOOP.

  • Help with Internal table - Urgent Please

    I had an internal table declared as below:
    DATA: BEGIN OF i_results OCCURS 0,
            pernr like p0014-pernr,
            begda like zhrccroll-begda,   "Cost center roll out begin date
            endda like zhrccroll-endda,    "Cost center roll out end date
            aedtm like p0014-aedtm,
            uname like p0014-uname,
            kostl like p0001-kostl,
           ittype(7),
          END OF i_results.
    And my SQL to populate the table based on some other results:
    select t1pernr t3begda t3endda t1aedtm t1uname t2kostl
      appending corresponding  fields of table i_results
      from pa0014 as t1
      inner join pa0001 as t2
      on t1pernr = t2pernr
      inner join zhrccroll as t3
      on t2kostl = t3kostl
      for all entries in i_it01
      where t1~pernr = i_it01-pernr
      and t2~kostl = i_it01-kostl
      and t3~kostl = i_it01-kostl
      and t3~syst = 'STAFF'
      and t1~aedtm = p_date
      and t1~uname in so_name.
    Everything was working great and now user wants to see additional dates on the report so I have to add couple of dates to internal table but unfortunately they have same names (begda, endda), Now I need internal table like this:
    DATA: BEGIN OF i_results OCCURS 0,
            pernr like p0014-pernr,
            begda like zhrccroll-begda,   "Cost center roll out begin date
            endda like zhrccroll-endda,    "Cost center roll out end date
            aedtm like p0014-aedtm,
            uname like p0014-uname,
            kostl like p0001-kostl,
            begda like p0014-begda,  "infotype begin date
            endda like p0014-endda,  "infotype end date
            ittype(7),
          END OF i_results.
    I cannot have duplicate declarations in internal table and also my SQL would not work. The new SQL would be:
    select t1pernr t3begda t3endda t1aedtm t1uname t2kostl
      t1begda t1endda
      appending corresponding  fields of table i_results
      from pa0014 as t1
      inner join pa0001 as t2
      on t1pernr = t2pernr
      inner join zhrccroll as t3
      on t2kostl = t3kostl
      for all entries in i_it01
      where t1~pernr = i_it01-pernr
      and t2~kostl = i_it01-kostl
      and t3~kostl = i_it01-kostl
      and t3~syst = 'STAFF'
      and t1~aedtm = p_date
      and t1~uname in so_name.
    This is not working either.
    Could comeone please help me how to acheive the desired result. I am trying to get all the data in one shot, and that is why I have the SQL above. Any ideas you could provide would be greatly appreciated.
    Thanks in advance.
    Mithun

    HI Mithun,
      To add to vishnu do not use "appending corresponding fields of"..
    1) if you are reading this data again and again then use
      "appending table itab"
    2) if it is triggered just once then use
      "into table itab"
    And also define ur itab as:
    DATA: BEGIN OF i_results OCCURS 0,
    pernr like p0014-pernr,
    ccbegda like zhrccroll-begda, "Cost center roll out begin date
    ccendda like zhrccroll-endda, "Cost center roll out end date
    aedtm like p0014-aedtm,
    uname like p0014-uname,
    kostl like p0001-kostl,
    begda like p0014-begda, "infotype begin date
    endda like p0014-endda, "infotype end date
    ittype(7),
    END OF i_results.
    and your select statement as:
    select t1pernr t3begda as ccbegda t3endda as ccenda t1aedtm t1~uname
    t2kostl t1begda t1~endda into table i_results
    from pa0014 as t1
    inner join pa0001 as t2
    on t1pernr = t2pernr
    inner join zhrccroll as t3
    on t2kostl = t3kostl
    for all entries in i_it01
    where t1~pernr = i_it01-pernr
    and t2~kostl = i_it01-kostl
    and t3~kostl = i_it01-kostl
    and t3~syst = 'STAFF'
    and t1~aedtm = p_date
    and t1~uname in so_name
    I am sure you need to tweak and twist the above statements a bit..
    Hope this helps..
    BR
    Rakesh
    PS: Please close the thread if your problem is solved..

  • Convert Columns into Rows (internal tables) - Urgent Help Pleasse..

    Hi friends i'm having a little problem and hope you can help me..Here's the situation.
    I have an internal table like shown below
    (Key)                   (Key)               (Key)          (Key)
    PATH_ID     |      GROUP     |      LINE     |     ATRIBUTE          |    VALUE
    ASLN2                1                      1                Company_Code       5146
    ASLN2                1                      1                Account_Code        400405
    ASLN2                1                      1                Profit_Centre          AA00N2
    ASLN2                1                      2                Company_Code       5146
    ASLN2                1                      2                Account_Code       400705
    ASLN2                1                      2                Profit_Centre          AA00N2
    ASLN3                1                      1                Company_Code       5146
    ASLN3                1                      1                Account_Code        400405
    ASLN3                1                      1                Profit_Centre          AA00N2
    ASLN3                1                      2                Company_Code       5146
    ASLN3                1                      2                Account_Code       400705
    ASLN3                1                      2                Profit_Centre          AA00N2
    and i want to convert this internal table to one like below
    PATH_ID      |      GROUP      |      LINE     |      Company Code   |    Account Code    |    Profit Centre
    ASLN2                1                      1                 5146                     400405                   AA00N2
    ASLN2                1                      2                 5146                     400705                   AA00N2
    ASLN3                1                      1                 5146                     400405                   AA00N2
    ASLN3                1                      2                 5146                     400705                   AA00N2
    but i'm a bit of stuck, all those key fields are making me confused...anyone have a marvelous ( ) idea of how to implement this transformation ?
    best regards,
    Ricardo Monteiro

    Itab1 with the structure PATH_ID | GROUP | LINE | ATRIBUTE | VALUE
    Itab2 with structure PATH_ID | GROUP | LINE | ATRIBUTE | VALUE
    Itab3 with the final structure PATH_ID | GROUP | LINE | Company Code | Account Code | Profit Centre
    move itab1 to itab2.
    sort itab2 by path_id group line.
    delete adjacent duplicates from itab2 comparing path_id group line.
    loop at itab2.
      clear itab3.
      move:
         itab2-pathid to itab3-pathid,
         itab2-group to itab3-group,
         itab2-line to itab3-line.  
      loop at itab1where pathid = itab2-pathid
                            and group = itab2-group
                            and line   = itab2-line.
          IF itab1-ATRIBUTE = ' Company_Code'.
             itab3-Company_Code = itab1-attribute.
          elseif itab1-ATRIBUTE = ' Account_Code '.
             itab3-Account_Code = itab1-attribute.
          elseif itab1-ATRIBUTE = ' Profit_Centre ' .
             itab3-profit_center = itab1-attribute.
          endif
      endloop.
      append itab3.
    endloop.
    try this.
    Thanks,
    rajinikanth

  • Help with logic on internal table

    Hi SDNers,
    I have 1st internal table call table it_tab with 20 fields. This table stores the data which will be passed to BDC.
    I have the 2nd internal table call table it_header. At run-time this table will store the header fields to be passed to BDC.
    The requirement is, when calling BDC I need to pass data from it_tab by group, each group must have the same data for the header fields. We only know which field is header field at run-time.
    Because ABAP does not support delete internal table with dynamic WHERE clause so my current solution does not work.
    Please let me know your idea.
    Thanks,
    Khanh

    you may have to run some nested loops & try to find solution using Field Symbol. This is discussed many time in forum but unfortunately no direct solution.
    Re: Dynamic where clause for LOOP AT internal table

  • Counting the Multiple Occurence of a record in the internal Table-Urgent

    Hi,
    I have an internal table with the following values
    a
    a
    a
    b
    b
    b
    c
    c
    I need to print a-2
                         b-3
                         c-2
    How do i accomplish this? i.e.,I need to count the multiple occurence of a field.Any input on this will be of great help.
    Thanks and Regards,
    Pavithra

    Hi,
    Find the piece of code below it can help you:
    data: begin of itab occurs 0,
               field1 type c,
               field2 type i,
            end of itab.
    data: itab2 like table of itab occurs 0 with header line.
    data: count type i.
    start-of-seleciton.
    itab-field1 = a.
    append itab.
    itab-field1 = a.
    append itab.
    itab-field1 = a.
    append itab.
    itab-field1 = b.
    append itab.
    sort itab by field1.
    loop at itab.
      count = count + 1.
    at end of field1.
      clear itab2.
      itab2-field1 = itab-field1.
      itab2-field2 = count.
      append itab2.
    endat.
    endloop.
    Dispaly output table.
    loop at itab2.
      write:/ itab2-field1, itab2-field2.
    endloop.
    Reward the points if it is helpful.

  • About logic in internal tables

    Hi friends,
    itab1 contains the following fields...
    F1         S1        S2
    206       111       222
    206       333       444
    I want above  fields in output table like this
    it_display.
    F1      m1       m2     m3       m4
    206    111      222    333      444
    please give some idea..
    thanks,
    kishore.

    Please check the sample code.
    REPORT  ztest_inc.
    DATA: BEGIN OF it_data OCCURS 0,
           f1(3),
           s1(3),
           s2(3),
          END OF it_data.
    DATA: BEGIN OF it_final OCCURS 0,
          f1(3),
          m1(3),
          m2(3),
          m3(3),
          m4(4),
         END OF it_final.
    it_data-f1 = '206'.
    it_data-s1 = '111'.
    it_data-s2 = '222'.
    APPEND it_data.
    it_data-f1 = '206'.
    it_data-s1 = '333'.
    it_data-s2 = '444'.
    APPEND it_data.
    *F1 m1 m2 m3 m4
    *206 111 222 333 444
    DATA: v_field(11),
          v_i(2) TYPE c.
    FIELD-SYMBOLS: <fs> TYPE ANY.
    v_i = 0.
    SORT it_data BY f1.
    LOOP AT it_data.
      v_i = v_i + 1.
      it_final-f1 = it_data-f1.
      CLEAR v_field.
      CONCATENATE 'IT_FINAL-M' v_i INTO v_field.
      CONDENSE v_field.
      ASSIGN (v_field) TO <fs>.
      <fs> = it_data-s1.
      v_i = v_i + 1.
      CLEAR v_field.
      CONCATENATE 'IT_FINAL-M' v_i INTO v_field.
      CONDENSE v_field.
      ASSIGN (v_field) TO <fs>.
      <fs> = it_data-s2.
      AT END OF f1.
        APPEND it_final.
      ENDAT.
    ENDLOOP.
    BREAK-POINT.

  • Dynamic internal table assignment.

    I have few internal tables in my bsp application but at a time i need to show 1 internal table based on some criteria into tableview.
    can anybody guide me how to do so, its really urgent
    Thanx,
    Abhijeet

    Hi Abhijeet,
    Just use field-symbols and ur problem will be solved.
    Check out the following code:
    <% Field-symbols <var> type any .
    .......logic for internal table selection..
      assign it2 to <var>.
    %>
    <htmlb:tableView id="tab1" table="<%=<var>%>">
    </htmlb:tableView>
    Hope it'll help u.
    Thanks & Regards,
    Ankur

Maybe you are looking for

  • Won't show up in my itunes

    hi just bought my ipad 2 yesterday and i plug it into my pc windows xp and it will not show up on my itunes on the left bar?

  • PDF/A Conversion Err :CIDset in subset font is incomplete & Character references .notdef glyphs

    I was trying to convert some PDF documents to PDF/A-3b. Using Acrobat XI Pro on a Windows Vista PC, the conversion proceeded fine, but I noticed the size of the converted file increased from 1.91 Mb to  16.8 Mb (See spage usage audits below). I expec

  • How do i create a static function in a class and implement ActionListener?

    i am trying to create a pop up dialog box in a seperate class. and i want to make the Function static, so that i only need to access it with the class name. But how do i have a ActionListener ? everything in a static function is static rite?

  • Load BLOB

    Hi oracle 10.2.0.1.0 I tried the following code CREATE OR REPLACE PROCEDURE load_lob AS   id         NUMBER;   image1     BLOB;   locator    BFILE;   bfile_len  NUMBER;   bf_desc    VARCHAR2(30);   bf_name    VARCHAR2(30);   bf_dir     VARCHAR2(30);

  • Could you please help me solve this kernel panic?

    HELLO. I HAVE AN I-MAC 24-INCH (EARLY 2009 MODEL), SOFTWARE MAVERICKS OS10.9.1. MY SCREEN FREEZES AND THEN SHUTS DOWNS QUITE OFTEN. WHEN I RESTART IT A WINDOW APPEARS WITH THE FOLLOWING MESSAGE: YOUR COMPUTER RESTARTED  BECAUSE OF A PROBLEM. PROBLEM