Application Development 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: 

How can I use a field symbol in a Concatenate

Former Member
0 Kudos

Hi to all,

I would like to use the value of a <FS> in a CONCATENATE command.

To use the CONCATENATE all fields must be type Characters. How can I transfer the content of my <FS> into a Character field without knowing the length?

At this time my coding looks like this but I am getting a dump during the execution at the CONCATENATE:

ASSIGN COMPONENT sy-index OF STRUCTURE <fs_dyn_wa> TO <fs_dyn_field1>.

CHECK sy-subrc EQ 0.

DESCRIBE FIELD <fs_dyn_field1> TYPE w_fld_typ LENGTH w_fld_len IN BYTE MODE.

IF w_fld_typ NE c_fld_typ_p.

DESCRIBE FIELD <fs_dyn_field1> TYPE w_fld_typ LENGTH w_fld_len IN CHARACTER MODE.

ENDIF.

IF w_pos EQ 1.

CONCATENATE wa_print_dta-ylinedta <fs_dyn_field1> INTO wa_print_dta-ylinedta.

ELSE.

CONCATENATE wa_print_dta-ylinedta(w_pos) <fs_dyn_field1> INTO wa_print_dta-ylinedta RESPECTING BLANKS.

ENDIF.

Thank you for your help.

BR,

Sylvain

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

I hope to understand your issue:

FIELD-SYMBOLS: <fs_char> type any.

data: v_len type i.
data: c1(20) type c,
      c2(20) type c.

v_len = strlen( <fs_char> ).

concatenate c1 <fs_char>(v_len) into c2 RESPECTING BLANKS.

Max

12 REPLIES 12

Former Member
0 Kudos

Hi

I hope to understand your issue:

FIELD-SYMBOLS: <fs_char> type any.

data: v_len type i.
data: c1(20) type c,
      c2(20) type c.

v_len = strlen( <fs_char> ).

concatenate c1 <fs_char>(v_len) into c2 RESPECTING BLANKS.

Max

0 Kudos

Hi,

Putting the field length after the <FS> name is helpfull but not when it is referencing a Pack (Type P) value.

Any idea how to avoid a dump iin the CONCATENATE when the <FS> contains a pack value?

Thanks,

Sylvain

0 Kudos

Hi

You can know the TYPE of the field-symbol by statament DESCRIBE FIELD, so if the type is not a CHAR you need to move the value of the field-symbols to a char variable.

This is my old abap code:

      ASSIGN COMPONENT SY-INDEX OF STRUCTURE RECORD_IN TO <FS_FIELD>.
      IF SY-SUBRC <> 0. EXIT. ENDIF.

      DESCRIBE FIELD <FS_FIELD> LENGTH LEN_FIELD  IN CHARACTER MODE
                                                        TYPE TYPE_FIELD.
      IF TYPE_FIELD = 'g'.
        LEN_FIELD = STRLEN( <FS_FIELD> ).
      ENDIF.

      CLEAR WA_VALUE.

      MOVE: <FS_FIELD> TO WA_VALUE(LEN_FIELD).

Max

Max

Edited by: max bianchi on Jul 29, 2011 5:50 PM

0 Kudos

Hi Max,

Thank you for your reply but I would like to know how do you define WA_VALUE?

Do you use CREATE DATA?

Thanks,

Sylvain

0 Kudos

Hi

in my situation:

DATA WA_VALUE(1000) TYPE C.

But I don't use the statament CONCATENATE but WRITE, if you use CONCATENATE i think it's can be a STRING

DATA WA_VALUE TYPE STRING.

MOVE: <FS_FIELD> TO WA_VALUE.

CONCATENATE wa_print_dta-ylinedta WA_VALUE INTO wa_print_dta-ylinedta.

Max

Edited by: max bianchi on Jul 29, 2011 6:28 PM

Former Member
0 Kudos

Hi Sylvain,

Field symbols should have issue with concatenate.

At the time of dump what was the value of w_pos

Regards

Ram

0 Kudos

typo error.

//Field symbols should not have issue with concatenate.

Clemenss
Active Contributor
0 Kudos

Hi,

try.
  IF w_pos EQ 1.
    CONCATENATE wa_print_dta-ylinedta <fs_dyn_field1> INTO wa_print_dta-ylinedta.
  ELSE.
    CONCATENATE wa_print_dta-ylinedta(w_pos) <fs_dyn_field1> INTO wa_print_dta-ylinedta RESPECTING BLANKS.
  ENDIF.
catch cx_root.
endtry.

... will just not take the non-characters.

or, using all fields (like may did):

data:
  lv_any type string.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs_dyn_wa> TO <fs_dyn_field1>.
CHECK sy-subrc EQ 0.
lv_any = <fs_dyn_field1>.
CONCATENATE wa_print_dta-ylinedta lv_any INTO wa_print_dta-ylinedta.

Regards

Clemens

Former Member
0 Kudos

As Max suggested

DATA WA_VALUE TYPE STRING.

MOVE: <FS_FIELD> TO WA_VALUE.

Use move for C, N, D, T values types and for Decimal, Int you should use write so it can be converted to o/p length.

WRITE <FS_FIELD> TO WA_VALUE.

Nitesh

SureshRa
Active Participant
0 Kudos

Hi Sylvain,

I guess your field symbol is of TYPE ANY. Please try the following

1. Declare a field symbol of TYPE C (e.g. <fs_char>)

2. Declare a data reference DREF

3. Once you find the length of your field symbol <fs_dyn_field1>, create a character data of that length

4. Assign the dereference of above created char object to <fs_char>

5. Use <fs_char> in CONCATENATE statement

Following could be the psuedo code:


FIELD-SYMBOLS <fs_char> TYPE c.
DATA dref TYPE REF TO DATA.
* Your code to find the length of the structure component into w_fld_len
CREATE DATA dref TYPE c LENGTH w_fld_len.
ASSIGN dref->* TO <fs_char>.
* Your code to concatenate using <fs_char>
IF w_pos EQ 1.
CONCATENATE wa_print_dta-ylinedta <fs_char> INTO wa_print_dta-ylinedta.
ELSE.
CONCATENATE wa_print_dta-ylinedta(w_pos) <fs_char> INTO wa_print_dta-ylinedta RESPECTING BLANKS.
ENDIF.

Cheers

Suresh

Former Member
0 Kudos

Hi Guys,

Thank you for all your answers. I was finally able to solve my issue by using the MOVE command instead of CONCATENATE.

Thanks,

Sylvain

jayaraj2018
Explorer
0 Kudos

Hi,

For anyone who come across such a problem, please try using && operator.

<fs> = <fs> && variables.

Regards,

Jay