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: 

ASSIGN field symbol with INT character

former_member186783
Participant
0 Kudos
749

Hi experts,

I would like to assign a fields symbol  with the casting type statement, but the types has got an int filed in it:

The type has got an LCHR field (1024 character long), so there is an INT4 field before that:

CSIZE                      TYPE     INT4

COMMENT_TRGT     TYPE     LCHR

I can't assign it simply to my field symbol because of the int4 field

ASSIGN gs_dblog-logdata TO <in_content>  CASTING TYPE (gs_dblog-tabname).

Can you please tell me, how can I assign my field symbol in this case?

Thanks,

N.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
169

Hi Nandor.

These seems to be a nested table I suppose else can you put the entire code...

If it is nested like

begin of mydata,

CSIZE                      TYPE     INT4,

COMMENT_TRGT     TYPE     LCHR,

end of mydata.

Begin of log_data,

field1 type a,

field.....

logdata type mydata,

end of log_data.

then use it like this

ASSIGN gs_dblog-logdata-comment_trgt TO <in_content>  CASTING TYPE (gs_dblog-tabname).

4 REPLIES 4

Former Member
0 Kudos
170

Hi Nandor.

These seems to be a nested table I suppose else can you put the entire code...

If it is nested like

begin of mydata,

CSIZE                      TYPE     INT4,

COMMENT_TRGT     TYPE     LCHR,

end of mydata.

Begin of log_data,

field1 type a,

field.....

logdata type mydata,

end of log_data.

then use it like this

ASSIGN gs_dblog-logdata-comment_trgt TO <in_content>  CASTING TYPE (gs_dblog-tabname).

0 Kudos
169

Hi Mohammed,

No. The problem is completely different. it doesn't matter if I include include my structure into another structure. I have an INTEGER field in my structure, and I can't assign it simply to a field symbol.

N.

0 Kudos
169

What is the type of <in_content> it should be ANY

0 Kudos
169

It doesn't matter if the TYPE is ANY. The main problem is the INT field. you have to go the structure's field one.by-one:

LOOP AT Pt_dblog INTO w_db_logs.
     CLEAR <wa>.
     MOVE-CORRESPONDING w_db_logs TO <wa>.
     MOVE: w_db_logs-logdata TO x_from_log(w_db_logs-dataln). "UC
     CREATE DATA logdata TYPE (logdata_type).                 "UC
     ASSIGN: logdata->* TO <logentry>.                        "UC
     TRY.
         ASSIGN <logentry> TO <logentry_x> CASTING.              "UC
       CATCH cx_sy_assign_cast_illegal_cast.
* table may contain string field
         is_deep_structure = true.
     ENDTRY.
* Schleife über Felder des Tabellenprotokolls
     LOOP AT p_w_logv-vstruc INTO struc.
       IF key_checked = false AND struc-keyflag = false.
* Schlüsselbereich ist jetzt vollständig: Gegen Selektionsbedingungen
* prüfen
         PERFORM check_key_selection USING w_db_logs
                                           <logentry>         "UC
                                   CHANGING p_w_logv        "UC
                                            log_kroepfchen
                                            key_rc.         "UC
         IF key_rc = 0.                                       "UC
* Keybereich entspricht den Selektionsbedingungen
           key_checked = true.
         ELSE.
* Keybereich entspricht nicht den Selektionsbedingungen
* --> Rekonstruktion abbrechen
           EXIT.
         ENDIF.
       ENDIF.
       IF w_tab_header-hist_only = false.                     "UC
         ASSIGN COMPONENT struc-viewfield                     "UC
          OF STRUCTURE <logentry> TO <value>.                 "UC
       ELSE.                                                  "UC
         IF 'Pgy' NS struc-inttype.
           ASSIGN <logentry>+struc-position(struc-flength) TO <value>
            TYPE struc-inttype.
         ELSEIF struc-inttype = 'P'.
           ASSIGN <logentry>+struc-position(struc-flength)
            TO <value> TYPE struc-inttype
            DECIMALS struc-decimals.
         ELSE.
* String field
         ENDIF.
       ENDIF.
       IF 'gy' NS struc-inttype.
         PERFORM get_table_field USING x_from_log               "UC
                                       w_db_logs-versno         "UC
                                       p_w_logv-maintview
                                       struc-viewfield
                                       struc-keyflag
                                CHANGING <value>                "UC
                                         w_dfies.
       ELSE.
* String field
       ENDIF.
       ASSIGN COMPONENT struc-viewfield OF STRUCTURE <wa> TO <fs_value>.
       <fs_value> = <value>.
     ENDLOOP.