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

Similar Messages

  • 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

  • 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

  • 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 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

  • 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

  • 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.

  • Logic for retreiving the values from a dynamic internal table

    Hi all,
    I have an issue with the logic to fetch data from a dynamic internal table into fields. let me give you guys an example the sy-tfill = 9 (subject to vary). I need to populate the fields.
    Regards,
    Sukumar

    Hi,
    this is for printing out the info in a dynamic table,
    it will work likewise to insert data.
    PARAMETERS:
      p_tabnam TYPE tabname DEFAULT 'DB_TABLE_NAME'.
    DATA:
      lv_dref TYPE REF TO data,
      ls_dd03l LIKE dd03l,
      lt_fieldname TYPE TABLE OF fieldname,
      ls_fieldname TYPE fieldname.
    FIELD-SYMBOLS:
      <fs> TYPE STANDARD TABLE,
      <wa_comp> TYPE fieldname,
      <wa_data> TYPE ANY,
      <wa_field> TYPE ANY.
    REFRESH lt_fieldname.
    SELECT * FROM dd03l INTO ls_dd03l
                       WHERE as4local = 'A'
                         AND as4vers  = '0000'
                         AND tabname  = p_tabnam
                       ORDER BY position.
      ls_fieldname = ls_dd03l-fieldname.
      APPEND ls_fieldname TO lt_fieldname.
    ENDSELECT.
    IF NOT ( lt_fieldname[] IS INITIAL ).
      CREATE DATA lv_dref TYPE TABLE OF (p_tabnam).
      ASSIGN lv_dref->* TO <fs>.
      SELECT * FROM (p_tabnam) INTO TABLE <fs>.
      WRITE:
        / 'CONTENTS OF TABLE', p_tabnam.
      LOOP AT <fs> ASSIGNING <wa_data>.
        SKIP.
        WRITE:
          / 'LINE', sy-tabix.
        ULINE.
        LOOP AT lt_fieldname ASSIGNING <wa_comp>.
          ASSIGN COMPONENT sy-tabix OF STRUCTURE <wa_data> TO <wa_field>.
          WRITE:
            / <wa_comp>, <wa_field>.
        ENDLOOP.
      ENDLOOP.
    ENDIF.
    grtz
    Koen

  • 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

  • How to delete the data inside a internal table?

    I got a internal table name g_itab1.
    currently my g_itab1 has a FNAME(50) component.
    Inside my component there is ADMINO, EYEAR, FIRSTNAME, LASTNAME and CONTACT.
    I want to clear away ADMINO, EYEAR, FIRSTNAME, LASTNAME and CONTACT inside my internal table.
    How do i clear it? i have tried using CLEAR g_itab1.
    It doesn't work.. the data are still inside.

    hi
                    DELETE TABLE itab WITH TABLE KEY k1 = v1 ... kn = vn.
    Example to delete all of the lines between 5 and 36 in a table of names where the entry begins with one of the letters 'A' to 'C'.
             DELETE  itab  FROM 5 TO 36 WHERE NAME CA 'ABC'.
    reward if useful
    regards
    sree

  • Logic issues for manipulation of internal table data

    Hi,
    I am having a issue with logic of one program.
    In the <b>XVBAP</b> internal table of <b>SO</b> User Exit.
    We will have fields like
    <b>UPDKZ, POSNR, UEPOS, ZZECD[Z-Field] etc.</b>
    Above fields are related to logic.
    1. Now my first point is:
    <b>We need to capture Records where UPDKZ='D' and ZZECD[Z-Field] is populated.</b>
    For this we will write code as below:
    <b>LOOP AT XVBAP WHERE UPDKZ     EQ C_D   AND
                        ZZECD     NE SPACE.
    Here we will store all fields in I_XVBAP I.Table
    ENDLOOP.</b>
    Supoose we have retrieved records as below:
    <b>VBELN, UPDKZ, POSNR, UEPOS, ZZECD
    100    D   000040   000030 Text1
    100    D   000050   000020 Text2
    100    D   000060   000000 Text3</b>
    2. My second point here is:
    <b>For Every Item[POSNR] we need to get the Higher level item from UEPOS field, If the Higher level Item also has UPDKZ = ‘D’, then move the base unit and all it’s components into an internal table. continue this process till UEPOS for POSNR is 000000 but High item should have UPDKZ = 'D', not only this all items in this chain should have UPDKZ = 'D'.</b>
    Ex:
    <b>Suppose for item 000050 UEPOS is 000020 then goto XVBAP with POSNR = UEPOS[000020] and UPDKZ = 'D' if yes and then pick up UEPOS for 000020 item and continue this process till UEPOS becomes 000000 and UPDKZ = 'D'.
    Here from Low level to High level all the chain items should have UPDKZ = 'D'. Then only write all items into Final Internal table.</b>
    <b>Need to do this process for all above rec's [40,50,60 - POSNR].</b>
    Can anybody provide me the logic for the above scenario.
    Thanks in advance.
    Thanks and Regards,
    Deep

    Hi Anurag,
    Your assumption is wrong.
    See first when we get into our logic we will get <b>XVBAP</b> data as below:
    <b>VBELN, POSNR, UEPOS, UPDKZ, ZZECD
    100,  10,  00,  D,  Text1
    100,  20,  00,   ,  Text2
    100,  30,  20,  D,  Text3
    100,  40,  30,  D,  Text4
    100,  50,  00,   ,  Text5
    100,  60,  00,   D, Text6
    100,  70,  60,   D, Text7</b>
    After we run first point we will get data as:
    Here logic is pick up data where <b>UPDKZ = D</b> and <b>ZZECD NE SPACE</b>.
    <b>VBELN, POSNR, UEPOS, UPDKZ, ZZECD
    100, 10, 00, D, Text1
    100, 30, 20, D, Text3
    100, 40, 30, D, Text4
    100, 60, 00, D, Text6
    100, 70, 60, D, Text7</b>
    Then we will goto second point:
    Here we need to look into <b>3</b> things totally in 2nd point:
    1. In loop Select the record which has <b>UEPOS EQ space</b>, <b>UPDKZ = D</b> and <b>POSNR</b> should not be <b>UEPOS</b> for any other record from above data from 1st point.
    <b>100, 10, 00, D, Text1</b>
    will be selected into final internal table as per this point.
    2. If for a POSNR value UEPOS NE SPACE, UPDKZ = D then goto UEPOS's POSNR in high level check there if UPDKZ = D and then wether UEPOS is ZERO (or) contains any value.
    If any value is there repeat the process till UEPOS become ZERO. Then for that final higher level item check UPDKZ value if it has value as 'D', If has then write all those records from low item to high item into final internal table.
    <b>100, 60, 00, D, Text6
    100, 70, 60, D, Text7</b>
    In above for Item 70[POSNR] we have UEPOS as 60 and UPDKZ as D. then we will goto UEPOS's POSNR, Now POSNR is 60 then check it's UEPOS it is ZERO so check UPDKZ because it is D write both items 60, 70 into final internal table.
    2. If for a POSNR value UEPOS NE SPACE, UPDKZ = D then goto UEPOS's POSNR in high level check there if UPDKZ = D and then wether UEPOS is ZERO (or) contains any value.
    If any value is there repeat the process till UEPOS become ZERO. Then for that final higher level item check UPDKZ value if it has value as 'D', If it does not have  UPDKZ as 'D' then don't write any item from low to high into final internal table.
    If we take the scenario of below rows:
    <b>100,  20,  00,   ,  Text2
    100,  30,  20,  D,  Text3
    100,  40,  30,  D,  Text4</b>
    POSNR-40 has UEPOS-30 & UPDKZ = D then UEPOS's POSNR-30 has UEPOS-20 and UPDKZ-D then UEPOS POSNR-20 has UEPOS as 00 then stop here and see UPDKZ which is ZERO so don't consider items 20,30,40 into final i.table.
    In the above chain in any record UPDKZ is not 'D' then skip the process anddon't write the records into final internal table.
    Final output will come as:
    <b>100, 10, 00, D, Text1</b>
    <b>100, 60, 00, D, Text6
    100, 70, 60, D, Text7</b>
    Thanks for all your efforts.
    Thanks,
    Deep

  • Internal table logic issue

    Hi All,
    I have one logical issue related to internal table manipulation.
    I have one internal table :
    I_DAT - This is related to Loading/Unloading of Goods.
    for example with 3 fields
    VSTEL, KUNNA, KMMANG.
    Now suppose my data looks like this after sorting:
    VSTEL   KUNNA    KMMANG
    100       -        -
    200       -        -
    300       -        -
    400       -        -
    -         500      X
    -         600      X
    -         700      X
    -         800      X
    Here 100,200,300,400 are Loading points.
    ANd 500,600,700,800 are unloading points.
    Now what i want is For loading & Unloading points i need to pick up Address and print one after other.
    But how they need to print is:
    FOR INITIAL LOADING OF
    ADDRESS- For 100
    FIRST STOP: FOR LOADING OF
    ADDRESS- For 200
    SECOND STOP: FOR LOADING OF
    ADDRESS- For 300
    Etc .....
    Then
    FOR UNLOADING OF:
    ADDRESS- For 400
    FIRST STOP: FOR UNLOADING OF
    etc.
    FINAL STOP: FOR FINAL UNLOADING OF
    We might get as many records :
    Can any body give me the logic:
    Printing Address is not a problem:
    But Above every address we need to print FIRST STOP, SECOND etc like that.
    For this i need logic.
    Can anybody give the solution!
    Thanks in advance.
    Thanks & Regards,
    Prasad.

    Try this.I think you want output like this......
    DATA: BEGIN OF LINE,
            CARRID   TYPE SBOOK-CARRID,
            CONNID   TYPE SBOOK-CONNID,
            FLDATE   TYPE SBOOK-FLDATE,
            CUSTTYPE TYPE SBOOK-CUSTTYPE,
            CLASS    TYPE SBOOK-CLASS,
            BOOKID   TYPE SBOOK-BOOKID,
          END OF LINE.
    DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY TABLE LINE.
    SELECT CARRID CONNID FLDATE CUSTTYPE CLASS BOOKID
           FROM SBOOK INTO CORRESPONDING FIELDS OF TABLE ITAB.
    LOOP AT ITAB INTO LINE.
      AT FIRST.
        WRITE / 'List of Bookings'.
        ULINE.
      ENDAT.
        AT NEW CARRID.
          WRITE: / 'Carrid:', LINE-CARRID.
        ENDAT.
          AT NEW CONNID.
            WRITE: / 'Connid:', LINE-CONNID.
          ENDAT.
            AT NEW FLDATE.
              WRITE: / 'Fldate:', LINE-FLDATE.
            ENDAT.
              AT NEW CUSTTYPE.
                WRITE: / 'Custtype:', LINE-CUSTTYPE.
              ENDAT.
                   WRITE: / LINE-BOOKID, LINE-CLASS.
                AT END OF CLASS.
                  ULINE.
                ENDAT.
    ENDLOOP.
    This is also helpful......
    LOOP AT <itab>.
      AT FIRST. ... ENDAT.
        AT NEW <f1>. ...... ENDAT.
          AT NEW <f2 >. ...... ENDAT.
              <single line processing>
          AT END OF <f2>. ... ENDAT.
        AT END OF <f1>. ... ENDAT.
      AT LAST. .... ENDAT.
    ENDLOOP.
    Regards
    Abhishek

  • Logic in a internal table

    hi experts , i need a logic
    i have a internal table itab_equi in that i am getting 11 values when i pass this internal table to another table using for all entries i will get 4 values in int_bmgkobj . i need logic for how to get the deleted values  i.e 9 values deleted . i need that value 9 values ..
    SELECT matnr
               sernr
               kunde
               objnr FROM equi
               INTO TABLE itab_equi  " i am getting 11 values here
               WHERE kunde = kunde .
    IF itab_equi[] IS NOT INITIAL.
          SELECT j_objnr
                       gwldt
                       gwlen FROM bgmkobj
                       INTO TABLE itab_bgmkobj " i am getting 4 values here
                       FOR ALL ENTRIES IN itab_equi
                       WHERE j_objnr = itab_equi-objnr .
    i need the deleted 9 values in a seperate internal table ..
    plz help me for this logic
    regards
    chinnaiya P

    HI,
    Check this ..
    SELECT matnr
               sernr
               kunde
               objnr FROM equi
               INTO TABLE itab_equi  " i am getting 11 values here
               WHERE kunde = kunde .
    IF itab_equi[] IS NOT INITIAL.
          SELECT j_objnr
                       gwldt
                       gwlen FROM bgmkobj
                       INTO TABLE itab_bgmkobj " i am getting 4 values here
                       FOR ALL ENTRIES IN itab_equi
                       WHERE j_objnr NE itab_equi-objnr .  "--> Check here
    Or
    Select all the data from bgmkobj into internal table  itab_bgmkobj.
    Loop the  itab_bgmkobj and check the entry using entries in internal table itab_equi..if found delete ..the left entries are what you required

Maybe you are looking for

  • Boot from floppy and install arch from flash stick - NO CDR - USB 1.1

    MY PREVIOUS POST BELOW BECAME A HARD DRIVE INSTALL POST WHICH HAS HELPED THOUGH ISN'T ON SUBJECT CURRENTLY AND I STILL NEED SOLUTION  - Now at day 3 :-) - sorry! I have old laptop with a very broken CDR... so just a floppy and a hard drive and 2 USB

  • Opening a report designed in Report 10g in Excel format

    I have passed the desformat parameter as spreadsheet but still i find unnecessary blank cells between columns and rows. The report is created in Report Builder 10g manually without using the Report wizard. I have tried to remove all the spaces betwee

  • Short dump: Conversion from type 'c' to 'v' not possible

    Hi, When do we get the following error? 'Conversion from type "c" to "v" not possible'. I am getting this dump when I try to assign a structure to a field symbol. This is happening only for a specific structure type.  Thanks in advance, Regards, Weno

  • Missing photos after importing from iPhoto

    I have a big iPhoto library that span from 2002 until today. Launching Photo for the first time started the import of the default iPhoto library, when finished the problem is not everything has been imported. I have not done photo by photo check, but

  • Settled Process Order

    After Settlement I need the Status of Process Order should become SETD/SETT. What are the  settings I have to do for this? Rajiv