How to select into a field of my internal table?

Howdy,
I have an internal table:
TYPES: BEGIN OF T_OUTPUT,
        EQUIPMENT         TYPE  EQUI-EQUNR,
        DESCRIPTION       TYPE  EQKT-EQKTX,
        EQUIPMENT_CAT     TYPE  EQUI-EQTYP,
        MASTER_WARRANTY    TYPE  BGMKOBJ-MGANR,
        DELIVERY           TYPE  LIKP-VBELN,
END OF T_OUTPUT.
DATA: ITAB_DETAILS TYPE STANDARD TABLE OF T_OUTPUT WITH HEADER LINE.
Now i'd like to do a slect from LIKP into the field ITAB_DETAILS-delivery, but his code doesn't work?
SELECT VBELN FROM LIKP INTO table ITAB_details-delivery
         WHERE  VBELN IN S_VBELN
         AND VKORG  = P_VKORG
         AND WERKS  = P_WERKS
         AND ERDAT IN S_ERDAT
         AND LFART IN S_LFART.
Does anyone know what I am doing wrong?
I need to keep the name of the field as 'delivery' and I don't want to change its order in the internal table - Otherwise I'd ahve used the 'MOVE CORRESPONDING' command.
Does anyone have any ideas?
Thanks!

STEVE,
Modified Code:
Get value for Delivery
   SELECT <b>SINGLE</b> VBELN FROM LIKP
       INTO ITAB_details-delivery
         WHERE  VBELN IN S_VBELN
         AND VKORG  = P_VKORG
         AND WERKS  = P_WERKS
         AND ERDAT IN S_ERDAT
         AND LFART IN S_LFART.
Insert into Internal Table ASSUMING u have values for
other fields in the Work Area.
<b>  append ITAB_DELIVERY.</b>
Thanks
Kam

Similar Messages

  • To populate values into single field in an internal table

    Hi Friends,
    How we need to populate values into single field in an internal table.
    E.g itab consits of single field ( name)
           i need to assign values to this field name .like
          peter,
          john,
          abrahm,
          daneyal
    Pls tell me i how i need to code for this
    Thanks ,
    Parnith

    Hi,
    Please look at the below code :
    DATA : BEGIN OF itab OCCURS 0 ,
             name(20) TYPE c,
           END OF itab.
    START-OF-SELECTION.
      itab-name = 'Peter'.
      APPEND itab.
      CLEAR itab.
      itab-name = 'John'.
      APPEND itab.
      CLEAR itab.
      itab-name = 'Abrahm'.
      APPEND itab.
      CLEAR itab.
      itab-name = 'Daneyal'.
      APPEND itab.
      CLEAR itab.
      LOOP AT itab.
        WRITE : / itab.
      ENDLOOP.
    Thanks,
    Sriram Ponna.

  • Splitting a string into respective fields of dynamic internal table

    Hi,
        I've a string concatenated with a separator. I've to split the string and assign it to the respective fields of an internal table, which is dynamic.
    Table name will be passed through selection screen. The data is coming from another system via RFC.
    Eg : String ITAB :
                                100;89001;EN;Material1;MATERIAL1
                                100;89002;EN;Material2;MATERIAL2
    The String ITAB may contain any master data. Let's say the above data is from MAKT table. So, I want to assign the above data to the respective fields of MAKT internal table(Dynamic).
    I heard, this requirement can be achieved using some standard CLASS.
    Please help me in doing this task.
    Regards,
    Sunny

    Hello,
    you can use dynamic programming for this issue, i.e.:
    DATA: gv_table_name   TYPE string,
          gr_type_desc    TYPE REF TO cl_abap_typedescr,
          gr_struct_desc  TYPE REF TO cl_abap_structdescr,
          gr_table_desc   TYPE REF TO cl_abap_tabledescr,
          gv_t            TYPE c,
          gv_comp         TYPE i,
          gr_table_ref    TYPE REF TO data,
          gr_struc_ref   TYPE REF TO data.
    DATA: gt_itab   TYPE TABLE OF string,
          gt_split  TYPE TABLE OF string,
          gv_str    TYPE string.
    FIELD-SYMBOLS: <table>    TYPE ANY TABLE,
                   <struct>   TYPE ANY,
                   <comp>     TYPE ANY.
    APPEND '100;89001;EN;Material1;MATERIAL1' TO gt_itab.
    APPEND '100;89002;EN;Material2;MATERIAL2' TO gt_itab.
    "go!
    gv_table_name = 'MAKT'.
    cl_abap_tabledescr=>describe_by_name(
          EXPORTING p_name = gv_table_name
          RECEIVING p_descr_ref = gr_type_desc
          EXCEPTIONS type_not_found = 4 ).
    gr_struct_desc ?= gr_type_desc.
    gr_table_desc = cl_abap_tabledescr=>create( gr_struct_desc ).
    CREATE DATA gr_table_ref TYPE HANDLE gr_table_desc.
    CREATE DATA gr_struc_ref TYPE HANDLE gr_struct_desc.
    ASSIGN gr_table_ref->* TO <table>.
    ASSIGN gr_struc_ref->* TO <struct>.
    DESCRIBE FIELD <struct> TYPE gv_t COMPONENTS gv_comp.
    LOOP AT gt_itab INTO gv_str.
      CLEAR: gt_split.
      SPLIT gv_str AT ';' INTO TABLE gt_split.
      DO gv_comp TIMES.
        READ TABLE gt_split INTO gv_str INDEX sy-index.
        ASSIGN COMPONENT sy-index OF STRUCTURE <struct> TO <comp>.
        <comp> = gv_str.
        CLEAR gv_str.
      ENDDO.
      INSERT <struct> INTO TABLE <table>.
    ENDLOOP.
    After this code you will have all data in <table> field symbol in proper type.
    Regards,
    Jacek

  • Coloring a field in the internal table

    Hi all,
    How can I color a field in the internal table knowing that I'm developing a classic report.
    Thanks in advance.

    hi,,,
    check this code.
    *-----TABLES DECLARATION
    tables : kna1,                     "Customer Master
           vbak,                     "Sales Document Header
             vbap,                     "Sales Document Item
             sscrfields.               "Screen Field Table
    &               D A T A   D E C L A R A T I O N                       &
    data : begin of it_kna1 occurs 0,
            kunnr type kna1-kunnr,      "Customer Number
            land1 type kna1-land1,      "Country Key
            name1 type kna1-name1,      "Name
            ort01 type kna1-ort01,      "City
           end of it_kna1.
    data : begin of it_kna2 occurs 0,
            kunnr type kna1-kunnr,      "Customer Number
            land1 type kna1-land1,      "Country Key
            name1 type kna1-name1,      "Name
            ort01 type kna1-ort01,      "City
           end of it_kna2.
    data:  begin of it_vbak occurs 0,
            vbeln type vbak-vbeln,      "Sales Document
            erdat type vbak-erdat,      "Date
            ernam type vbak-ernam,      "Name of Person
            auart type vbak-auart,      "Sales Document Type
           end of it_vbak.
    data:  begin of it_vbap occurs 0,
            vbeln type vbap-vbeln,      "Sales Document
            posnr type vbap-posnr,      "Sales Document Item
            matnr type vbap-matnr,      "Material Number
            matkl type vbap-matkl,      "Material group
           end of it_vbap.
    data: v_count type int4,           "Current Row Index
           v_line like sy-lisel,        "Contents of selected line
           v_kunnr like kna1-kunnr.
    &                S E L E C T I O N  S C R E E N                       &
    selection-screen begin of block b1 with frame title text-001.
    selection-screen begin of line.
    parameters : rb1 radiobutton group g1 default 'X'.
    selection-screen comment 5(20) text-002 for field rb1.
    selection-screen end of line.
    select-options : so_kunnr for kna1-kunnr obligatory.
    parameters : p_hits(3) type c.
    selection-screen begin of line.
    parameters : rb2 radiobutton group g1.
    selection-screen comment 5(20) text-003 for field rb2.
    selection-screen end of line.
    parameters : p_file like rlgrap-filename default 'c:\test'.
    selection-screen pushbutton /33(10) custl user-command push1.
    selection-screen pushbutton 58(10) custd user-command push2.
    selection-screen end of block b1.
    &                  I N I T I A L I Z A T I O N                        &
    initialization.
      move 'LOAD' to custl.
      move 'DISP' to custd.
    &                  A T  L I N E  S E L E C T I O N                    &
    at selection-screen.
      perform validate_kunnr.
    &  A T  S E L E C T I O N  S C R E E N  O N  V A L U E-R E Q U E S T  &
    at selection-screen on value-request for p_file.
      call function 'F4_FILENAME'
        exporting
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
          field_name    = ' '
        importing
          file_name     = p_file.
    &              S T A R T  O F  S E L E C T I O N                      &
    start-of-selection.
      perform cust_details.
    &              S T A R T  O F  S E L E C T I O N                      &
    top-of-page.
      format color 3 intensified off.
      write :/02(25) sy-repid.
      write : 39(15) 'Page'(010), sy-pagno.
      format color off.
      format color 6 intensified off.
      format color col_heading.
      uline at :/1(60).
      write: /1 sy-vline,
              2 'Cust Number'(000),
              14 sy-vline,
              16 'Country'(007),
              25 sy-vline,
              26 'City'(008),
              42 sy-vline,
              43 'Region'(009),
              60 sy-vline.
      uline at :/1(60).
      format color col_heading off.
    &   T O P  O F  P A G E  D U R I N G  L I N E  S E L E C T I O N      &
    top-of-page during line-selection.
      if sy-lsind eq 1 or sy-ucomm eq 'VBAK'.
        format color col_heading.
        uline at :/1(60).
        write : /1 sy-vline,
                     2 'Docu No.'(011),
                     14 sy-vline,
                     16 'Date'(012),
                     26 sy-vline,
                     27 'Name'(013),
                     42 sy-vline,
                     43 'DType'(014),
                     60 sy-vline.
        uline at :/1(60).
      elseif sy-lsind eq 2 or sy-ucomm eq 'VBAK'.
        set pf-status space.
        uline at :/1(60).
        write : /1 sy-vline,
                     2 'Docu No.'(015),
                     14 sy-vline,
                     16 'Sales Item'(016),
                     25 sy-vline,
                     26 'Mat No'(017),
                     42 sy-vline,
                     43 vbap-matkl,
                     50 'Mat Grp'(018),
                     60 sy-vline.
        uline at :/1(60).
      endif.
    &  AT USER-COMMAND                                                    &
    at user-command.
      case sy-ucomm.
        when 'VBAK'.
          perform sales_item.
        when 'DELIVERY'.
          clear it_vbak-vbeln.
          get cursor value it_vbak-vbeln.
          set parameter id 'AUN' field it_vbak-vbeln.
          call transaction 'VA03' and skip first screen.
        when 'DISP'.
          perform display_basic.
      endcase.
    &      AT LINE SELECTION                                              &
    at line-selection.
      if sy-lsind = 1.
        set pf-status 'DDDD'.
        perform sales_header.
      elseif  sy-lsind = 2.
      case sy-ucomm.
        when 'PICK'.
        set pf-status space.
        perform sales_item.
        when 'DELIVERY'.
          clear it_vbak-vbeln.
          get cursor value it_vbak-vbeln.
          set parameter id 'AUN' field it_vbak-vbeln.
          call transaction 'VA03' and skip first screen.
        when 'DISP'.
          perform display_basic.
      endcase.
       PERFORM sales_item.
      endif.
    &  AT USER-COMMAND                                                    &
    at user-command.
      case sy-ucomm.
        when 'VBAK'.
          perform sales_item.
        when 'DELIVERY'.
          clear it_vbak-vbeln.
          get cursor value it_vbak-vbeln.
          set parameter id 'AUN' field it_vbak-vbeln.
          call transaction 'VA03' and skip first screen.
        when 'DISP'.
          perform display_basic.
      endcase.
    &      Form  CUST_DETAILS                                             &
    form cust_details .
      select kunnr
             land1
             name1
             ort01
             from kna1
             into table it_kna1
             where kunnr in so_kunnr.
      if sy-subrc <> 0.
        message 'SELECT VALID CUST NO' type 'I'.
      else.
        loop at it_kna1.
         v_count = v_count + 1.
          if sy-tabix < p_hits.
         IF v_count <= p_hits.
            move it_kna1 to it_kna2.
            append it_kna2.
          else.
            exit.
          endif.
        endloop.
      endif.
      if not it_kna2[] is initial.
        loop at it_kna2.
          write : /1 sy-vline,
                   2 it_kna2-kunnr,
                   14 sy-vline,
                   16 it_kna2-land1,
                   25 sy-vline,
                   26 it_kna2-name1,
                   42 sy-vline,
                   43 it_kna2-ort01,
                   60 sy-vline.
          uline at :/1(60).
        endloop.
      endif.
    endform.                    " CUST_DETAILS
    **&      Form  load_file
    *form load_file .
    *endform.                    " load_file
    **&      Form  disp_file
    *form disp_file .
    *endform.                    " disp_file
    *&      Form  VALIDATE_KUNNR
    form validate_kunnr .
      select single kunnr
                    from kna1
                    into kna1
                    where kunnr = so_kunnr.
    endform.                    " VALIDATE_KUNNR
    *&      Form  SALES_HEADER
    form sales_header .
    data : v_kna1(13).
    v_kna1 = 'IT_KNA2-KUNNR'.
    *get cursor line sy-lilli value v_line
    clear v_kunnr.
      get cursor  field v_kna1 value v_kunnr.
    v_kunnr = v_line+1(10).
      call function 'CONVERSION_EXIT_ALPHA_INPUT'
        exporting
          input  = v_kunnr
        importing
          output = v_kunnr.
      select vbeln
             erdat
             ernam
             auart
             from vbak
             into table it_vbak
             where  kunnr = v_kunnr.
      if sy-subrc = 0.
        loop at it_vbak.
          write : /1 sy-vline,
                   2 it_vbak-vbeln,
                   14 sy-vline,
                   16 it_vbak-erdat,
                   26 sy-vline,
                   27 it_vbak-ernam,
                   42 sy-vline,
                   43 it_vbak-auart,
                   60 sy-vline.
          uline at :/1(60).
        endloop.
      endif.
    endform.                    " SALES_HEADER
    *&      Form  SALES_ITEM
    form sales_item .
    data : v_vbeln(13).
    v_vbeln = 'IT_VBAK-VBELN'.
    clear it_vbak-vbeln.
    get cursor  field v_vbeln value it_vbak-vbeln.
      call function 'CONVERSION_EXIT_ALPHA_INPUT'
        exporting
          input  = it_vbak-vbeln
        importing
          output = it_vbak-vbeln.
      select vbeln
             posnr
             matnr
             matkl
      from vbap
      into table it_vbap
      where vbeln = it_vbak-vbeln.
      loop at it_vbap .
        write : /1 sy-vline,
                   2 it_vbap-vbeln,
                   14 sy-vline,
                   16 it_vbap-posnr,
                   25 sy-vline,
                   26 it_vbap-matnr,
                   42 sy-vline,
                   43 it_vbap-matkl,
                   60 sy-vline.
        uline at :/1(60).
      endloop.
    endform.                    " SALES_ITEM
    *&      Form  DISP_DOCU
    form display_basic .
      loop at it_kna1 into it_kna1.
        format hotspot on.
        write : /03 it_kna1-kunnr,
                 24  it_kna1-name1.
        hide it_kna1-kunnr.
      endloop.
    endform.                    " display_basic
    pls reward if useful
    regards,
    rekha

  • Fields in an internal table

    How to find number of fields in an internal table ?
    my requirement is i have 20 internal tables and the data is being uploaded into an application server. so how to find no of fields in a particular internal table

    concatenate all the fields and move them to final internal table , call the function module "GET_COMPONENT_LIST" and pass the work area of the final internal table in the parameter fieldname
    ***For getting no of FIELDS in an internal table ********
    CALL FUNCTION 'GET_COMPONENT_LIST'
      EXPORTING
        PROGRAM          = syrepid
        FIELDNAME        = 't_payr'
      TABLES
        COMPONENTS       = fieldlist.
    describe table fieldlist lines pyr_no_fields.
    ********end of getting no of fields**********
    TRANSFER wa_mat_out_head TO P_FNAME.
    LOOP AT GT_PAYR.
    MOVE:  GT_payr-LIFNR TO T_payr-lifnr,
           GT_payr-ZBUKR TO T_payr-zbukr,
           GT_payr-LAUFD TO T_payr-LAUFD,
           GT_payr-CHECT TO T_payr-CHECT,
           GT_payr-RWBTR TO T_payr-RWBTR.
    Concatenate T_payr-lifnr  t_payr-zbukr T_payr-laufd T_payr-chect
                T_payr-rwbtr into wa_mat_out-rec SEPARATED by ',' .

  • Select into specified fields

    In the select statement, how can I specify fields of an internal table which I want to be filled from a database table? Is it possible to define in INTO clause that I want db_field1 to be copied into itab_field3?

    ... INTO (f1, ..., fn)
    Places the result set in the target area (f1, ..., fn). The fields of the result set are transported to the target fields fi from left to right. INTO (f1, ..., fn) is allowed only if a list with n elements is also specified in the SELECT clause.
    If the result of a selection is a table, the data is retrieved in a processing loop introduced by SELECT and concluded by ENDSELECT. The processing passes through the loop once for each line read. If the result is a single record, the closing ENDSELECT is omitted.
    Example
    Output a list of all airlines (with short description and name):
    TABLES SCARR.
    DATA:  CARRID   LIKE SCARR-CARRID,
           CARRNAME LIKE SCARR-CARRNAME,
    SELECT CARRID CARRNAME
           INTO (CARRID, CARRNAME)
           FROM SCARR.
      WRITE: / CARRID, CARRNAME.
    ENDSELECT
    If u have defined an internal tabel and in select query u r retrieving a few fields then use INTO CORRESPONDING FIELDS OF..
    DATA: Begin of tab occurs 0,
      matnr like mara-matnr,
      maktl like mara maktl,
    end of tab.
    select matnr from
           mara <b>into corresponding fields of table tab</b>
           where matnr IN s_matnr.
    Try this one.
    Message was edited by: Judith Jessie Selvi

  • How to join  fields from different internal tables and display into one int

    hai i have one doubt...
    how to join  fields from different internal tables and display into one internal table..
    if anybody know the ans for this qus tell me......

    hii
    you can read data as per condition and then can join in one internal table using READ and APPEND statement..refer to following code.
    SELECT bwkey                         " Valuation Area
             bukrs                         " Company Code
        FROM t001k
        INTO TABLE i_t001k
       WHERE bukrs IN s_bukrs.
      IF sy-subrc EQ 0.
        SELECT bwkey                       " Valuation Area
               werks                       " Plant
          FROM t001w
          INTO TABLE i_t001w
           FOR ALL ENTRIES IN i_t001k
         WHERE bwkey = i_t001k-bwkey
           AND werks IN s_werks.
        IF sy-subrc EQ 0.
          LOOP AT i_output INTO wa_output.
            READ TABLE i_t001w INTO wa_t001w WITH KEY werks = wa_output-werks.
            READ TABLE i_t001k INTO wa_t001k WITH KEY bwkey = wa_t001w-bwkey.
            wa_output-bukrs = wa_t001k-bukrs.
            MODIFY i_output FROM wa_output.
            CLEAR wa_output.
          ENDLOOP.                         " LOOP AT i_output
        ENDIF.                             " IF sy-subrc EQ 0
    regards
    twinkal

  • How to select first several records from a database table by using select?

    Hi,
       I want to select first 100 records from a database table by using select clause. How to write it?
       Thanks a lot!

    hai long!
                 well select statement is used to retrive
    records from the database.
    following is the syntax to be used.
    1) select *  into corresponding fields of itab from basetable where condition.
    endselect.
      ex: select * into corresponding fields of itab from mara
                where matnr >= '1' and  matnr <= '100'.
           append itab.
          endselect.
    select * is a loop statement.it will execute till matnr is less than or equal to 100.
    note: you can also mention the required field names in the select statement otherwise it will select all the field from table mara.
    note: itab means your internal table name.
    hope you got the required thing.if it really solved u r problem then award me the suitable points.<b></b>

  • How to increase field size in Internal table

    Hi friends,
    I want to concatenate around 20 fields in one internal table field,
    i declared the destination filed as character, now i am able to get around 12 to 13 fileds only , how to increase the length of this field to include all fields ?
    or how can i do this ? can any body help me ?
    I concatenate this to create a file  which will be send as email attachment.
    its very urgent issue, kindly help me to resolve as early as possible.
    Thanks in advance.
    Joseph

    Hi,
    Use the string data type..
    Example
    DATA: IT_STRING TYPE STRING OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF WA,
                 MATNR(18),
                 WERKS(4),
                 VBELN(10),
               END OF WA.
    CONCATENATE WA-MATNR WA-WERKS WA-VBELN INTO IT_STRING.
    APPEND IT_STRING.
    Thanks,
    Naren

  • How to fetch the SAP Standard Prog. built internal table into my_z_prog.?

    Hi Experts,
    Pls. let me know that,
    How to fetch the SAP Standard Prog. built internal table into my_z_prog.?
    For more explannation, pls. see my other thread with name of yestrday,
    SUBMIT RFGLBALANCE WITH selection criteria, then How to get resulted itab?
    thanq

    Hi
    Suppose RFGLBALANCE is your standard program and you have an internal table named I_RFGLBALANCE.
    And lets say your Z program name is Z_SRINIVAS.
    First find out the type of the internal table you want in your Z-program in the standard program. And declare an internal table of similar type in your Z-program.
    I hope you can do this much.
    Later wherever you are putting the below mentioned code.
    SUBMIT RFGLBALANCE WITH selection criteria
    Write the code which i have written.Obviously modify it to suit your requirement.
    Please show what is not working fine so that even anyone else can help you with the problem you are facing.
    Regards,
    Mayank

  • How to find the structure fields data in database tables?

    how to find the structure fields data in database tables?

    Your question doesn't appear to be Web Dynpro ABAP related. Please only post questions in this forum if they are directly Web Dynpro ABAP related.  There are several other more general ABAP related forums.

  • First occurence of a value from a  field in the internal table.

    How to select the first occurence of a value from a field in an internal table ?
    I don think , we can use select query .
    Any suggestions?
    provide syntaxs also .

    Hi...
    You have to use this code.
    DATA : Begin of IT_MARA occurs 0,
                 mtart type mara-mtart,
                 matnr type mara-matnr,
                 meins type mara-meins,
              END OF IT_MARA.
    START-of-SELECTION.
      SELECT MTART MATNR MEINS FROM MARA INTO TABLE IT_MARA.
    END-OF-SELECTION.
    LOOP AT  IT_MARA.
    <b>  AT NEW MTART.      "This will trigger for every first/new value of the field
                 <<<<WRITE YOUR CODE here>>
       ENDAT.</b>
    ENDLOOP.
    You can also use.
    LOOP AT  IT_MARA.
    <b> <b>  ON CHANGE OF IT_MARA-TART.   
                 <<<<WRITE YOUR CODE here>>
       ENDON.</b></b>
    ENDLOOP.
    <b>Reward if Helpful.</b>

  • Dynamic field access in internal tables

    Hi everyone.
    I woulkd like to know if there is any way to identify the fields of an internal table at runtime. I'm creating a method in a class, and i would like to accept any itab as a paramter and then access the fields of that itab. I currently have the itab passing no problem using field symbols, and i am able to loop at the data, but i am unsure how to get the field names.
    Any suggestions?
    Thanks!

    Hi,
    Check the code below:
    REPORT ZYKTEST3 .
    DATA: d_ref TYPE REF TO data,
    d_ref2 TYPE REF TO data,
    i_alv_cat TYPE TABLE OF lvc_s_fcat,
    ls_alv_cat LIKE LINE OF i_alv_cat.
    TYPES: tabname LIKE dcobjdef-name ,
    fieldname LIKE dcobjdef-name,
    desc LIKE dntab-fieldtext.
    PARAMETER: p_tablen TYPE tabname. -
    > Input table field
    DATA: BEGIN OF itab OCCURS 0.
    INCLUDE STRUCTURE dntab.
    DATA: END OF itab.
    FIELD-SYMBOLS : <f_fs> TYPE table,
    <f_fs1> TYPE table,
    <f_fs2> TYPE ANY,
    <f_fs3> TYPE ANY,
    <f_fs4> type any,
    <f_field> TYPE ANY.
    REFRESH itab.
    CALL FUNCTION 'NAMETAB_GET' -
    > Fetches the fields
    EXPORTING
    langu = sy-langu
    tabname = p_tablen
    TABLES
    nametab = itab
    EXCEPTIONS
    no_texts_found = 1.
    LOOP AT itab .
    ls_alv_cat-fieldname = itab-fieldname.
    ls_alv_cat-ref_table = p_tablen.
    ls_alv_cat-ref_field = itab-fieldname.
    ls_alv_cat-seltext = itab-fieldtext.
    ls_alv_cat-reptext = itab-fieldtext.
    APPEND ls_alv_cat TO i_alv_cat.
    ENDLOOP.
    internal table build
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = i_alv_cat
    IMPORTING
    ep_table = d_ref.
    ASSIGN d_ref->* TO <f_fs>. -
    > Dynamic table creation with fields of the table
    DATA: l_field TYPE fieldname,
    l_field1 type fieldname.
    SELECT * FROM (p_tablen) INTO CORRESPONDING FIELDS OF TABLE <f_fs>.
    Fetching of the data from the table
    LOOP AT <f_fs> ASSIGNING <f_fs2>.
    Here u can check the validations and process
    ASSIGN COMPONENT 2 OF STRUCTURE <f_fs2> TO <f_fs3>.
    ASSIGN COMPONENT 3 OF STRUCTURE <f_fs2> TO <f_fs4>.
    IF sy-subrc = 0.
    MOVE <f_fs3> TO l_field.
    MOVE <f_fs4> TO l_field1.
    WRITE:/1 l_field(20),
    22 l_field1(10).
    ENDIF.
    ENDLOOP.
    Regards
    Kannaiah

  • Colour to field in an internal table

    how to colour a particular data in a particular field of an internal table.

    See this
    1. add one more field to ur final internal table say COLOR(4)
    2. in layout wa_layout-style_fname = 'COLOR'. " if its grid
    wa_layout-style_fieldname = 'COLOR'. "if its list
    3. read table itab index 3.
    itab-color = 'C410'.
    modify itab index 3
    4. see program SHOWCOLO for all color codes
    1. Add a field of data type CHAR(3) to the internal output table.
    2. Enter the color code in the appropriate field of the row to be colored in the internal
    output table:
    Code: 'Cxy'
    C = Color (all codes begin with 'C')
    x = color number ('1' - '9')
    y = highlight ('0' = off, '1' = on)
    3. Assign the internal output table color code field name to the IS_LAYOUT importing
    structure IS_LAYOUT-INFO_FIELDNAME field and pass this structure in the ALV call
    interface.
    To enable row coloring, you should add an additional field to your list data table. It should be of character type and length at least 4. This field will contain the color code for the row. So, let’s modify declaration of our list data table “gt_list”.
    you should fill the color code to this field. Its format will be the same as explained before at section C.6.3. But how will ALV Grid know that you have loaded the color data for the row to this field. So, you make it know this by passing the name of the field containing color codes to the field “INFO_FNAME” of the layout structure.
    e.g.
    ps_layout-info_fname = <field_name_containing_color_codes>. “e.g. ‘ROWCOLOR’
    You can fill that field anytime during execution. But, of course, due to the flow logic of screens, it will be reflected to your list display as soon as an ALV refresh occurs.
    You can color an entire row as described in the next section. However, this method is less time consuming.
    Coloring Individual Cells
    This is the last point about coloring procedures for the ALV Grid. The procedure is similar to coloring an entire row. However, since an individual cell can be addressed with two parameters we will need something more. What is meant by “more” is a table type structure to be included into the structure of the list data table. It seems strange, because including it will make our list data structure deep. But anyhow ALV Grid control handles this.
    The structure that should be included must be of type “LVC_T_SCOL”. If you want to color the entire row, this inner table should contain only one row with field “fname” is set to space, some color value at field “col”, “0” or “1” at fields “int” (intensified) and “inv” (inverse).
    If you want to color individual cells, then for each cell column, append a line to this inner table which also contains the column name at field “fname”. It is obvious that you can color an entire column by filling this inner table with a row for that column for each row in the list data table.
    If it is in ALv refer the following code:
    *& Report  ZDEMO_ALVGRID                                               *
    *& Example of a simple ALV Grid Report                                 *
    *& The basic ALV grid, Enhanced to display each row in a different     *
    *& colour                                                              *
    REPORT  zdemo_alvgrid                 .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
      line_color(4) type c,     "Used to store row color attributes
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    There are a number of ways to create a fieldcat.
    For the purpose of this example i will build the fieldcatalog manualy
    by populating the internal table fields individually and then
    appending the rows. This method can be the most time consuming but can
    also allow you  more control of the final product.
    Beware though, you need to ensure that all fields required are
    populated. When using some of functionality available via ALV, such as
    total. You may need to provide more information than if you were
    simply displaying the result
                  I.e. Field type may be required in-order for
                       the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    Set layout field for row attributes(i.e. color)
      gd_layout-info_fieldname =      'LINE_COLOR'.
    gd_layout-totals_only        = 'X'.
    gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
                                            "click(press f2)
    gd_layout-zebra             = 'X'.
    gd_layout-group_change_edit = 'X'.
    gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
          Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
               i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
               i_callback_user_command = 'USER_COMMAND'
               i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
               it_special_groups       = gd_tabgroup
               IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
               is_variant              = z_template
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
      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.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    data: ld_color(1) type c.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into table it_ekko.
    *Populate field with color attributes
    loop at it_ekko into wa_ekko.
    Populate color variable with colour properties
    Char 1 = C (This is a color property)
    Char 2 = 3 (Color codes: 1 - 7)
    Char 3 = Intensified on/off ( 1 or 0 )
    Char 4 = Inverse display on/off ( 1 or 0 )
              i.e. wa_ekko-line_color = 'C410'
      ld_color = ld_color + 1.
    Only 7 colours so need to reset color value
      if ld_color = 8.
        ld_color = 1.
      endif.
      concatenate 'C' ld_color '10' into wa_ekko-line_color.
    wa_ekko-line_color = 'C410'.
      modify it_ekko from wa_ekko.
    endloop.
    endform.                    " DATA_RETRIEVAL
    Please give me reward points...

  • How can I get Number of Lines from internal table?

    Hello at all,
    i have in my Report a internal Table, which have many KUNNR.
    For example the internal Table:
    MANDT.......KUNNR......NAME.........FIRSTNAME........CITY
    ...040..........12345.........Owen............Michael........Liverpool
    ...040..........12345.........Owen............Michael........Liverpool
    ...040..........99999.......Johnson.......... Jeffrey........London
    ...040..........12345.........Owen............Michael........Liverpool
    ...040..........55555.......Hardley.......... Kingston.......Birmingham
    I want to know, how many same KUNNR are existing in the internal Table?
    In my example i need the result 3, because their is existing 3 times the Kunnr 12345 in the internal Table.
    Have anyone an idea, how can I resolve this problem?
    Edited by: Thomas Zloch on Jun 21, 2010 2:55 PM - one question mark at a time is sufficient

    Hi,
    1.Create two internal tables of same type and sort according to Kunnr then Delete the
    adjusent duplicates by comparing KUNNR
    2.Sort the table by KUNNR and use ON change of Concept in that Just increment the counter.
    I am writing the sample logic here.
    tables kna1.
    data: t_kna1 type table of kna1,
             w_kunnr type kna1-kunnr,
             counter type i," Holds No.of KUNNRs in the T_kna1
             t_kna2 type table of kna1.
    select * from kna1 into table kna1 up to 100 rows.
    t_kna2[] = t_kna1[].
    delete t_kna2 by kunnr.
    delete adjusent duplicates from t_kna2 by comparing kunnr."1st Method
    read table t_kna2 transporting no-fields.
    counter = sy-tfill."1st Method
    loop at t_kna1 into kna1."2nd Method
    at first.
    w_kunnr = kna1-kunnr .
    counter = 1.
    endat.
    if w_kunnr ne kna1-kunnr.
    counter = counter + 1.
    endif.
    endloop.
    Note : Here I used a sample table KNA1 in this there are no Duplicates of KUNNR .

Maybe you are looking for

  • Mail slows to a trickle and then freezes - Activity Monitor shows all OK

    I've been having this issue recently where I will be typing an email and I notice I begin to outpace Mail's ability to display the letters I am typing until finally it stops altogether. At this point Mail becomes almost completely unresponsive. I can

  • Submit Statement WD4A

    Hi,         I am looking to run a Function Module at as a background job in a abap webdynpro application.Am using the following code to run the job by passing internal table (dynpro) to the FM . Is it possible to use the below code in ABAP Webdynpro.

  • Accessing global address list

    Hi, We have Outlook 2003 installed with the Collaboration Suite and Outlook Connector. In Outlook VBA I am trying to access the Oracle global address list with MAPI. This takes about 20 minutes to return the selected recipients from the address list

  • Management Point 0Bytes and Critical

    Hi All Using System Center 2012 R2 and have deployed the Management Point role to two different Windows Server 2012 R2 servers. Now within the SCCM Console under Site Status my Management Point role shows as Critical and the Total Size shows 0 Bytes

  • When does the new iTunes comes out?

    Hey guys, when does actually the new iTunes come out?