cancel
Showing results for 
Search instead for 
Did you mean: 

dynamic table and field symbols!

Former Member
0 Kudos

hi,

I AM converting an interactive report to alv format,

the output should be based on the users input, for eg) if the user is typing tranport no and the system eg)rd2 to rd4 .

it should display like this..

transportno transtype rd2 rd2(100) rd2(200) rd3 rd3(100) rd4 rd4(100) rd4(200) rd4(220) etc...

okay...

i am using field catalog to get the header part,

this header is dynamically generated and its working fine..

the first 2 columns or static it will not change, but the other sys column will be changing okay..

next,

based on the tranport type like values I, E, H, it will put a tick mark on the system field columns.

so what i am doing is i cannot assign a standard internal table with a proper stucture, therefore i am using a int table of type 1000 characters, with this i am concatenating the values and finally i got proper values which i need to be populated to ALV

I AM GETTING AN ERROR SOURCE STRUCTURE IS NOT MATCHING THE TARGET STRUCT.

I ALSO TRIED IN using field symbols..

but i dont know how to populated the values to the int table with the same struct to ALV.

I AM ALSO ATTACHING THE CODE FOR YOU....

INTERNAL TABLE OF 1000 CHAR.

DATA:  gt_itab TYPE zrepair_itab_table_type,
       wa_itab TYPE zrepair_itab_structure.

FIELD CATLOG
DATA: fieldcat    TYPE lvc_t_fcat,
      lt_alv_cat  TYPE TABLE OF lvc_s_fcat,
      ls_alv_cat  LIKE LINE OF lt_alv_cat,
      wa_fieldcat TYPE lvc_s_fcat.


wa_fieldcat-fieldname = 'TYP'.
  wa_fieldcat-dd_outlen = 10.
  wa_fieldcat-outputlen = 13.
  wa_fieldcat-coltext = 'TRANSPORT NO'.
  wa_fieldcat-seltext = 'TRANS'.
  wa_fieldcat-col_pos = 1.
  APPEND wa_fieldcat TO fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-fieldname = 'TY'.
  wa_fieldcat-dd_outlen = 1.
  wa_fieldcat-outputlen = 4.
  wa_fieldcat-coltext = 'TYPE'.
  wa_fieldcat-seltext = 'TYPE'.
  wa_fieldcat-col_pos = 2.
  APPEND wa_fieldcat TO fieldcat.
  CLEAR wa_fieldcat.

  w_color = 0.
  DATA : fieldname(10) TYPE c.
  DATA : d1 TYPE c VALUE '('.
  DATA : d2 TYPE c VALUE ')',sys(7),count TYPE i,count1(2).
*  Constants icon_id_okay LIKE icon-id value '@01@'.
  DATA : icon LIKE icon-id.
  count = 1.
  LOOP AT t_syscli.
    IF NOT t_syscli-mandt IS INITIAL.
      CONCATENATE t_syscli-sysid d1 t_syscli-mandt d2 INTO fieldname.

    ELSE.
      CONCATENATE t_syscli-sysid  ' ' INTO fieldname SEPARATED BY
      space.
    ENDIF.


    count1 = count.
    CONCATENATE 'SYSID' count1 INTO sys.
    wa_fieldcat-fieldname = sys.
    wa_fieldcat-symbol  = 'X'.
*    wa_fieldcat-EMPHASIZE = 'C811'.
    wa_fieldcat-outputlen = 9.
    wa_fieldcat-coltext = fieldname.
    wa_fieldcat-seltext = 'MANDT'.
    wa_fieldcat-col_pos = a.
    CLEAR fieldname.

    APPEND wa_fieldcat TO fieldcat.
    a = a + 1.
    CLEAR wa_fieldcat.
    count = count + 1.
    CLEAR: sys,count1.
  ENDLOOP.

&&&&&VALUES CONCATENATION IS DONE HERE

 DATA : cou TYPE i VALUE 0 .
  LOOP AT t_migtab.
    w_trtype = t_migtab-trtype.

    AT NEW trkorr.
      IF cou = 1 .
        APPEND wa_itab TO gt_itab.
        CLEAR wa_itab.
      ENDIF.
      cou = 1.
      wa_itab = t_migtab-trkorr.
*      WRITE: SY-VLINE, T_MIGTAB-TRKORR(10), SY-VLINE NO-GAP.
      HIDE t_migtab-trkorr.
      PERFORM write_type USING w_trtype.
*-  Write client template
      LOOP AT t_syscli.
        IF t_syscli-mandt IS INITIAL.
          CONCATENATE wa_itab 'W' INTO wa_itab SEPARATED BY space.
        ELSE.
          CONCATENATE wa_itab 'E' INTO wa_itab SEPARATED BY space.
        ENDIF.
      ENDLOOP.
    ENDAT.


THE OUTPUT WHICH I AM GETTING FROM GT_ITAB IS OKAY..

ITS LIKE THIS SAY FOR RD2 AND RDK1913456  ALONE: RDK1913456 E S E E E 



I AM PASSING THIS IN FIELD SYMBOLS
FIELD-SYMBOLS: <FS_DATA> type ref to DATA,
               <FS_1> type standard table,
               <FS_2>,
               <FS_3>.
            



  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
*    I_STYLE_TABLE             =
      it_fieldcatalog           = fieldcat
    IMPORTING
      ep_table                  = <fs_data>
*    E_STYLE_FNAME             =
    EXCEPTIONS
      generate_subpool_dir_full = 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.
**
*** So <FS_1> now points to our dynamic internal table.

  ASSIGN <fs_data>->* TO <fs_1>.

*** Next step is to create a work area for our dynamic internal table.

  CREATE DATA new_line LIKE LINE OF <fs_1>.

*** A field-symbol to access that work area
  ASSIGN new_line->*  TO <fs_2>.

  LOOP AT gt_itab assigning <fs_2>.

 ASSIGN <fs_2> TO <fs_1>.
ASSIGN COMPONENT  wa_fieldcat-fieldname  OF STRUCTURE <fs_2> TO <fs_1>.

 ENDLOOP.

alv output:

 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
       EXPORTING
            i_bypassing_buffer = 'X'
            i_callback_program = repid
*            is_layout_lvc     = layout
            it_fieldcat_lvc    = fieldcat[]
            i_save             = 'U'
*            is_variant         = variant
            it_events          = events[]
            it_event_exit      = evexits[]
       TABLES
            t_outtab           = <fs_1>

            EXCEPTIONS
            program_error      = 1
            OTHERS             = 2.


ENDFORM.                    " DISPLAY_ALV

now please tell me hoe can i passs the values from the field symbols to alv or from gt_itab to alv.

if i pass the gt_itab directly i getting an eror target struct is not matching...

is it possible to create a internal table of type field symbol, or i am getting the values in gt_itab can i pass it to a proper int table, but that should be dynamic, because the values or changing based on the user input...

any help and guidance will be appreciated...

thanks in advance

from

rajkumar

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

hi raj...

Can u tell me how did u pass the field-symbol to function

'REUSE_ALV_LIST_DISPLAY'?

Because i m developing an ALV in which i have to pass the dynamic internal table. And that i have created with the help of field-symbols.

Plz reply me ASAP....

Former Member
0 Kudos

hi guys,

thankyou very much for the response, the problem is only with the field symbol assignment.

i tried in assinging in another way i got the correct structure and then i passed it to the alv finnaly i got the output.

now i am trying to print some contents in the end of list or end of the page.

i am using the slis events, its putting a box but the values is not getting populated.

if anyone knows reg this please help me.

Former Member
0 Kudos

Hi Raj,

I was working sometime back in April this year with SAP on a project which was ALV based. That time we faced the same problem with END_OF_PAGE event. To my knowledge there is some problem and so the event does not work properly. Probably you will have to work out some other way.

regards,

Satya

former_member183804
Active Contributor
0 Kudos

There seems to be a dedicade thread regarding this issue:

Best Regards

Klaus

former_member183804
Active Contributor
0 Kudos

Hello Rajkumar,

the type of the internal table must always fit to the field catalogue (the structure of the line must contain the same components as mentioned in the FC).

With there are few types only using a case with dedicated vars might be the easiest approch. For a fully dynamic approach there is a most helpful WebLog:

[Dynamic Internal Table|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/1011] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken];

Kind Regards

Klaus

FredericGirod
Active Contributor
0 Kudos

Hi Rajkumar,

I try to read your question, it's a little bit hard on the morning I understand you try to make an alv on a dynamic internal table. I have do this before, but not with FM, with Object.

I don't understand the part of the internal table of 1000 Char ?

Could you put the whole source code ?

Or if you want I could post my code (very long).

Regards

Frédéric Girod.

athavanraja
Active Contributor
0 Kudos

If you post this question in ABAP forum you would get a better response.

Regards

Raja

former_member374
Active Contributor
0 Kudos

Hi Raja,

Good comment. I moved the post and his chances for a good responds is so much better now.

Hope you understand and don't forget to give points when you get a good answer.

See: /people/mark.finnern/blog/2004/08/10/spread-the-love

All the best, Mark.