Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dynamic Work Area Field name Assignment.

vivekananthan_sellavel
Active Participant
0 Likes
3,000

hi Guru,

data: it_SFLIGHT type TABLE OF SFLIGHT,

wa_SFLIGHT TYPE SFLIGHT,

lv_field TYPE string.

lv_field = 'CARRID'. " Field name

wa_SFLIGHT-<lv_field> = 'vivek'. " Assigning Value to workarea.

When i try this i am getting the error.

Regards.

Vivekananthan.S

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,140

Hi

The way you are creating is wrong. Please follow the steps below.

1. Create a field catalogue with the fields (dynamic).

2. Pass it to the below class

IF NOT i_fldcat[] IS INITIAL.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = i_fldcat[]

IMPORTING

ep_table = i_table

EXCEPTIONS

generate_subpool_dir_full = 1

OTHERS = 2

.

IF sy-subrc <> 0.

ENDIF. " IF sy-subrc <> 0.

3. Assign the table to one dynamic table and work area.

ASSIGN i_table->* TO <i_output>.

CREATE DATA fs_line LIKE LINE OF <i_output>.

ASSIGN fs_line->* TO <fs_output>.

ENDIF. " IF NOT i_fldcat[] IS INITIAL.

So that you can achieve your job.

Venkat.

4 REPLIES 4
Read only

Former Member
0 Likes
1,140

Hi,


assign (p_tc_name) to <tc>.


TYPES:
  BEGIN OF st_mytable,
    name1 TYPE string,
    name2 TYPE string,
    age TYPE i,
  END OF st_mytable.

DATA:
  gi_mytable TYPE STANDARD TABLE OF st_mytable,
  g_mytable  TYPE st_mytable.

*------------------------------
* Define field symbols
*------------------------------
FIELD-SYMBOLS:
  <myfield1> TYPE ANY,
  <myfield2> TYPE ANY,
  <myfield3> TYPE ANY,
  <myline>  TYPE ANY.

*------------------------------
* Fill table with data
*------------------------------
g_mytable-name1 = 'John'.
g_mytable-name2 = 'Johnson'.
g_mytable-age   = 25.
APPEND g_mytable TO gi_mytable.

g_mytable-name1 = 'Claudio'.
g_mytable-name2 = 'Jensen'.
g_mytable-age   =  45.
APPEND g_mytable TO gi_mytable.

*------------------------------
* The normal way to do it
*------------------------------

LOOP AT gi_mytable INTO g_mytable.
  WRITE: / g_mytable-name1, g_mytable-name2 ,g_mytable-age.
ENDLOOP.

SKIP 2.

*------------------------------
* Do it with field symbols
*------------------------------
LOOP AT gi_mytable ASSIGNING <myline>.
  ASSIGN COMPONENT 1 OF STRUCTURE <myline> TO <myfield1>.
  ASSIGN COMPONENT 2 OF STRUCTURE <myline> TO <myfield2>.
  ASSIGN component 3 OF STRUCTURE <myline> TO <myfield3>.
  WRITE: / <myfield1>,<myfield2>,<myfield3>.
ENDLOOP.

*------------------------------
* Unassign field symbols
*------------------------------
UNASSIGN <myfield1>.
UNASSIGN <myfield2>.
UNASSIGN <myfield3>.
UNASSIGN <myline>.

Regards,

Prabhudas

Read only

0 Likes
1,140

hi guru,

g_mytable- name1 = 'John'.

g_mytable -name2 = 'Johnson'.

g_mytable- age = 25.

I should assign the the Field name directlly(Name1,Name2.Age).

Regards

Vivekananthan.S

Read only

Former Member
0 Likes
1,140

>

> hi Guru,

>

>

> data: it_SFLIGHT type TABLE OF SFLIGHT,

> wa_SFLIGHT TYPE SFLIGHT,

> lv_field TYPE string.

> lv_field = 'CARRID'. " Field name

> wa_SFLIGHT-<lv_field> = 'vivek'. " Assigning Value to workarea.

>

> When i try this i am getting the error.

>

>

> Regards.

> Vivekananthan.S

see the example...


*   Moving Batch Characteristic values to proper fields
  LOOP AT t_zcxref_classes INTO wa_zcxref_classes.
    IF wa_zcxref_classes-z7b1_main_column IS NOT INITIAL.
      CONCATENATE 'wa_7b1_in-'  wa_zcxref_classes-z7b1_main_column
             INTO w_char_name.
      CONDENSE w_char_name.
      ASSIGN (w_char_name) TO <fs_char_name>.
      IF sy-subrc = 0.
        <fs_char_name> = wa_zcxref_classes-atwrt.
*         Updating  Batch Characteristic values
        MODIFY t_7b1_in FROM wa_7b1_in INDEX 1
                 TRANSPORTING (wa_zcxref_classes-z7b1_main_column).
      ENDIF.
    ENDIF.
    CLEAR w_char_name.
  ENDLOOP.

for your cobe..


concatenate 'wa_SFLIGHT-'  <lv_field>  into w_char_name.
ASSIGN (w_char_name) TO <lv_field>.


Regards,

Prabhudas

Read only

Former Member
0 Likes
1,141

Hi

The way you are creating is wrong. Please follow the steps below.

1. Create a field catalogue with the fields (dynamic).

2. Pass it to the below class

IF NOT i_fldcat[] IS INITIAL.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = i_fldcat[]

IMPORTING

ep_table = i_table

EXCEPTIONS

generate_subpool_dir_full = 1

OTHERS = 2

.

IF sy-subrc <> 0.

ENDIF. " IF sy-subrc <> 0.

3. Assign the table to one dynamic table and work area.

ASSIGN i_table->* TO <i_output>.

CREATE DATA fs_line LIKE LINE OF <i_output>.

ASSIGN fs_line->* TO <fs_output>.

ENDIF. " IF NOT i_fldcat[] IS INITIAL.

So that you can achieve your job.

Venkat.