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: 

Assigning a field symbol to an object

Former Member
0 Kudos
958

Hi guys,

I have an issue. How do I move the contents of <fs_retreq_i> (highlighted in yellow below)

to data object lt_retreq_i? The insert statement I am trying below is not working.

TYPES: BEGIN OF zurdp_line,

                        record  Types  GUID_32,

lv_F0018   Type CHAR10,

lv_F0019   Type CHAR20,

lv_F001A  Type CHAR10 ,

             ENDOF zurdp_line.

DATA: ls_extension2      TYPE crmt_extension2_com,
ls_retreq_i            
TYPE REF TO zurdp_line,
lt_retreq_i            
TYPE REF TO zurdp_line
ct_extension2          
TYPE crmt_extension2_comt.

FIELD-SYMBOLS: <ls_extension2> TYPE crmt_extension2_com,
<ls_retreq_i>
TYPE zurdp_line,
<fs_retreq_i>
TYPE zurdp_line,
<fs_data>
TYPE zurdp_line.

CLEAR ls_extension2.

<fs_retreq_i>
-record_id = '12345543'.
<fs_retreq_i>
-lv_f0018 = 'Text1'.
<fs_retreq_i>
-lv_f0019 = 'Text2'.
<fs_retreq_i>
-lv_f001a = 'Text3'.


*    INSERT  <fs_retreq_i> INTO TABLE lt_retreq_i->*.

ls_extension2
-data = lt_retreq_i.
INSERT ls_extension2 INTO TABLE ct_extension2.

Regards,

1 ACCEPTED SOLUTION

Former Member
0 Kudos
264

Hi guys,

I have to assign ls_extension2-data = lt_retreq_i.

So I can't define  lt_retreq_i as TABLE OF zurdp_line.

lt_retreq_i has to be type ref to CRMT_EXTENSION2_COM.


CRMT_EXTENSION2_COM looks like below


REF_HANDLE TYPE CRMT_HANDLE

REF_GUID   TYPE CRMT_OBJECT_GUID

REF_KIND   TYPE CRMT_OBJECT_KIND

OBJECT     TYPE CRMT_OBJECT_NAME

DATA       TYPE DATA


The objective is to be able to assign


ls_extension2-data = lt_retreq_i.



Please assist.



6 REPLIES 6

Former Member
0 Kudos
264

Correct the following statements as below and check.


ls_retreq_i             TYPE REF TO TABLE OF zurdp_line,


INSERT  <fs_retreq_i> INTO TABLE lt_retreq_i->*. (removing the arrow and asterisk)

Former Member
0 Kudos
264

Hi Sibusiso,

Following is the corrected code:

TYPES: BEGIN OF zurdp_line,

         record  
TYPE  guid_32,

         lv_f0018
TYPE char10,

         lv_f0019
TYPE char20,

         lv_f001a
TYPE char10,

      
END OF zurdp_line.


DATA: ls_extension2 TYPE crmt_extension2_com,

      ls_retreq_i  
TYPE zurdp_line,

      lt_retreq_i  
TYPE TABLE OF zurdp_line,

      ct_extension2
TYPE crmt_extension2_comt.


FIELD-SYMBOLS: <ls_extension2> TYPE crmt_extension2_com,

               <ls_retreq_i>  
TYPE zurdp_line,

               <fs_retreq_i>  
TYPE zurdp_line,

               <fs_data>      
TYPE zurdp_line.


CLEAR ls_extension2.


ASSIGN ls_retreq_i TO <fs_retreq_i>.


IF <fs_retreq_i> IS ASSIGNED.

<fs_retreq_i>-record = '12345543'.

<fs_retreq_i>-lv_f0018 = 'Text1'.
<fs_retreq_i>-lv_f0019 = 'Text2'.
<fs_retreq_i>-lv_f001a = 'Text3'.

ENDIF.


INSERT  <fs_retreq_i> INTO TABLE lt_retreq_i.

Regards,

Sai Kiran.

Former Member
0 Kudos
265

Hi guys,

I have to assign ls_extension2-data = lt_retreq_i.

So I can't define  lt_retreq_i as TABLE OF zurdp_line.

lt_retreq_i has to be type ref to CRMT_EXTENSION2_COM.


CRMT_EXTENSION2_COM looks like below


REF_HANDLE TYPE CRMT_HANDLE

REF_GUID   TYPE CRMT_OBJECT_GUID

REF_KIND   TYPE CRMT_OBJECT_KIND

OBJECT     TYPE CRMT_OBJECT_NAME

DATA       TYPE DATA


The objective is to be able to assign


ls_extension2-data = lt_retreq_i.



Please assist.



0 Kudos
264

Hi Sibusiso,

The table lt_retreq_i does not need to be of the type CRMT_EXTENSION2_COM to be copied into.

1. Instead of declaring zurdp_line in this program as a structure, use SE11 and create the structure with the same fields that you had mentioned in your original post, in the ABAP repository.

2. Create a table type, zturdp_line in the repository using SE11 using the above structure. Once done, the following code pretty much achieves what you need, with a few changes included in BOLD letters.

DATA: ls_extension2 TYPE crmt_extension2_com,
      ls_retreq_i   TYPE zurdp_line,
      lt_retreq_i   TYPE REF TO zturdp_line,
      ct_extension2 TYPE crmt_extension2_comt.

FIELD-SYMBOLS: <ls_extension2> TYPE crmt_extension2_com,
               <ls_retreq_i>   TYPE zurdp_line,
               <fs_retreq_i>   TYPE zurdp_line,
               <fs_data>       TYPE zurdp_line.

CREATE DATA lt_retreq_i.

CLEAR ls_extension2.

ASSIGN ls_retreq_i TO <fs_retreq_i>.

IF <fs_retreq_i> IS ASSIGNED.
  <fs_retreq_i>-record = '12345543'.
  <fs_retreq_i>-lv_f0018 = 'Text1'.
  <fs_retreq_i>-lv_f0019 = 'Text2'.
  <fs_retreq_i>-lv_f001a = 'Text3'.
ENDIF.

INSERT  <fs_retreq_i> INTO TABLE lt_retreq_i->*.

ls_extension2-data = lt_retreq_i.

INSERT ls_extension2 INTO TABLE ct_extension2.

Regards,

Sai Kiran.

0 Kudos
264

Hey Sai,

This works 100%. I now have my data sitting in ls_extension2-data.

Thank you ,very much appricated.

Regards,

Sibusiso

0 Kudos
264

Hi Sibusiso,

I am glad you found it helpful.

Cheers,

Sai Kiran.