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.

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

  • 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

  • Question about Subroutine and Internal tables

    See I  have this code.
    TABLES: SFLIGHT.
        TYPES: BEGIN OF LINE,
               Carrid like SFLIGHT-CARRID,
               Connid like SFLIGHT-CONNID,
               Fldate like SFLIGHT-FLDATE,
               Seatsmax like SFLIGHT-SEATSMAX,
               Seatsocc like SFLIGHT-SEATSOCC,
               Percen type p decimals 2,
               END OF LINE.
       DATA: ISFLIGHT TYPE STANDARD TABLE OF LINE INITIAL SIZE 10 WITH HEADER LINE.
       DATA: Percent type p decimals 2.
       PARAMETERS: CID LIKE SFLIGHT-CARRID.
       DATA: Num type I value 0.
       INITIALIZATION.
       CID = '004'.
       SELECT CARRID CONNID FLDATE  SEATSMAX  SEATSOCC FROM SFLIGHT INTO TABLE ISFLIGHT WHERE CARRID = CID.
    So far I've gotten this far. but now I need to compute for the percentage, which I'm required to do in a subroutine.
    So I tried
    FORM U TABLES ISFLIGHT STRUCTURE SFLIGHT.
    ISFLIGHT-Percen = ( ISFLIGHT-Seatsocc / ISFLIGHT-Seatsmax ) * 100.
    ENDFORM.
    But I keep getting an error o that. It keeps telling me that ISFLIGHT does not have a Percen field. Also I'm suppose to use a pass by value to this subroutine but I don't know what that means.
    Basically I need to compute for the percentage and insert it tot he internal table. which I would sort by percentage. After which I'm suppose to print the ouput by passing the internal table to the subroutine.
    I know I'm doing something wrong but I just don't know how to fix this since I only started working on subroutines today. Any help would be appreciated.

    Hi.
    line defined in data dictionary. Try this:
    TABLES: sflight.
    DATA: BEGIN OF my_line,
    carrid LIKE sflight-carrid,
    connid LIKE sflight-connid,
    fldate LIKE sflight-fldate,
    seatsmax LIKE sflight-seatsmax,
    seatsocc LIKE sflight-seatsocc,
    percen TYPE p DECIMALS 2,
    END OF my_line.
    DATA: isflight LIKE my_line OCCURS 10 WITH HEADER LINE.
    DATA: percent TYPE p DECIMALS 2.
    PARAMETERS: cid LIKE sflight-carrid.
    DATA: num TYPE i VALUE 0.
    INITIALIZATION.
      cid = '004'.
      SELECT carrid connid fldate seatsmax seatsocc FROM sflight INTO TABLE
      isflight WHERE carrid = cid.
    FORM u TABLES isflight STRUCTURE my_line.
      isflight-percen = ( isflight-seatsocc / isflight-seatsmax ) * 100.
    ENDFORM.                    "U
    regards
    Walter Habich

  • Problem about casting in internal tables

    Hello,
    TYPES:
      BEGIN OF ts_matnr,
        matnr TYPE matnr,
        objct TYPE cuobj,
      END   OF ts_matnr.
      tables: mara.
    DATA:
      myStatus(20) type c,
      mySTANDARDCLASS(20) type c,
      gt_matnr TYPE STANDARD TABLE OF ts_matnr WITH DEFAULT KEY,
      gs_matnr LIKE LINE OF gt_matnr,
      gs_mara  TYPE mara.
    SELECT-OPTIONS:
      pr_matnr FOR gs_mara-matnr.
    START-OF-SELECTION.
    SELECT matnr
           matnr AS objct
           FROM mara
           INTO CORRESPONDING FIELDS OF TABLE gt_matnr WHERE matnr IN pr_matnr.
    I want to write both the normal String and the value as object  into the table. But there is a error at the select saying the fields can't be converted to target field.
    I don't know what the problem is. Can you see it?
    Edited by: Daniel Gerne on Apr 23, 2008 2:31 PM

    unfortunately, I just saw that I just walked around my problem instead of solving it. The reason I want to have this MATNR is that I need to use it as Objectkey for a BAPI call:
    LOOP AT gt_matnr INTO gs_matnr.
    CALL FUNCTION 'BAPI_OBJCL_GETDETAIL_KEY'
      EXPORTING
    *    CLOBJECTKEY           = gt_matnr-objct "nicht Tabelle, sondern Arbeitsbereich
        CLOBJECTKEY           = gs_matnr-objct "hat Typ OBJCT <=> BAPI1003_KEY-OBJECT_GUID
        CLASSNUM              = 'FARBIGE_UNTERLAGEN'
    *   KEYDATE               = SY-DATUM
    *   LANGUAGE              = SY-LANGU
    IMPORTING
       STATUS                = myStatus
       STANDARDCLASS         = mySTANDARDCLASS.
    *  TABLES
    *    ALLOCVALUESNUM        =
    *    ALLOCVALUESCHAR       =
    *    ALLOCVALUESCURR       =
    *    RETURN                =.
    ENDLOOP.
    But with the type from Shiva's code the debugger says that the given parameter has a wrong type.I just can't get this BAPI to work. I want to use it to get the classification information about a material.

  • Regarding 'FREE' ABAP Keyword in the local internal table

    Hi Experts,
    //sorry for my english ;(
    Our ABAP Development leader forced us to use  FREE ABAP Keyword on Local internal table like below situation.
    and I really don't get it.
    -below-
    FORM GET_DATA.
      DATA: LT_ITAB TYPE TABLE OF SFLIGHT.
      SELECT * FROM ZTABLE INTO TABLE LT_TABLE
            FOR ALL ENTRIES IN LT_ITAB
        WHERE KKEY = LT_ITAB-CARRID.
    "// WHY DO I HAVE TO USE THIS CODE
        FREE LT_ITAB.
    ENDFORM.
    I know that GC(garbage collector) will release memory area of LT_ITAB.
    but why do i have to release directly FREE LT_ITAB memory area?
    cause to take in short time memory advantage of before GC calling?
    thanks.

    Guys, why don't you read ABAP help?
    From ABAP help about FREE:
    For internal tables, FREE has the same effect as the REFRESH statement, though the entire memory area occupied by the table rows is released, and the initial memory area remains unoccupied
    About REFRESH:
    This statement sets an internal table itab to its initial value, meaning that it deletes all rows of the internal table. The memory space required for the table is freed up to the initial memory size INITIAL SIZE. For itab, you must specify an internal table.
    To delete all rows and free the entire memory space occupied by rows, you can use the statement FREE.
    About INITAIL SIZE:
    After the optional addition INITIAL SIZE, you can specify a number of rows n as a numeric literal or numeric constant to adjust the size of the first block in the memory that is reserved by the system for an internal table of the table type. Without this addition, if the number 0 is entered, or the value of n exceeds a maximum value, the system automatically allocates an appropriate memory area.
    To summarize:
    Using free allows you to immediately free the initial space reserved by the kernel for an internal table.
    I am lazy to look for it, but I don't think it ever exceeds few Kb.
    regards,
      Yuri

  • 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

  • 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

  • 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

  • Confused about logical table source

    Hi,
    I'm confused about logical table source(LTS), there are 'General', 'Column Mapping', 'Content' tabs in
    LTS, in General tab ,there are some information,like 'Map to there tables' and 'joins',
    just here, we have created relationships in physical layer and BMM layer, so I would like to ask what's the use of the 'joins' here?

    Hi Alpha,
    Valid query, when you establish a complex join it is always between a logical fact and dimension table.Consider a scenario,
    Example:w_person_dx is an extension table not directly joined to a fact but joins to a dimension w_person_d.
    When you model the person_d tables in BMM, you ll have a single logical table with w_person_d as source.If you have to pull columns from both w_person_d and w_person_dx tables in a report, you add dx table as inner join to persond table in the general tab.Now when you check your physical query, you can see the inner join fired between the two dimensions.
    Rgds,
    Dpka

Maybe you are looking for

  • How do I find 'Other' when it comes to my hard drive so I can delete unwanted files?

    Can someone please help me with this problem? When pulling up my system profiler, the catagories under storage are: Audio Movies Photos Apps Backups Other How do I find where the files that are located in the 'Other' group. So I can delete unwanted f

  • Problem with IDoc scenario - IDocs do not aarive to XI

    Hi guys! I have a problem with IDoc->XI->File scenario. Colleagues send IDocs from R/3 and they are not in the XI. In R/3 they look like if they were correctly sent, however, I can not see them in sxmb monitor. BUT, when they send them again explicit

  • How do I wipe an iBook for selling

    Hi All - I have Macs to well and I want to wipe the drive so no financial/passwords are able to used by the nefarious.  Can someone let me know how to do it, or should I take it to Apple? Thanks much!

  • PR type

    Hello friend We use SRM server 5.5 with classic scenario. We will use the BADI BBP_SC_TRANSFER_BE to determine the PR type and number range. But I’m not sure the following logic is correct. Could you check this? We have two PR type in R/3. 1) KGPR (G

  • Reset and close ur  webdynpro application

    hi     I have a RESET button in the main window  which   need to be reset and  moved to starting stage  after certain operations have been done when i click on RESET button , and other is close button where  the whole WEBDYNPRO APPLICATION has to be