2007 Jan 04 1:56 PM
Good morning,
I have a Table "ZMY_TABLE" with the next fields:
- ZMY_FIELD1
- ZUSER
- ZPASSWORD
But ZMY_FIELD1 is another structure with the next values:
- ZAN_STRING
- ZANOTHER_STRUCT
And ZANOTHER_STRUCT has the values:
- ZFIELD
- ZVALUE.
How is possible insert data to the last fields (ZFIELD & ZVALUE). I am using internatl tables and work areas but I have´nt found the way to assing values.
Thanks a lot,
Best & Regards,
Hernán Restrepo C.
2007 Jan 04 2:08 PM
Hi,
Please use following code.
data: lt_my_table type table of zmy_table.
ls_my_table type zmy_table.
ls_my_table -zuser = 'Test'.
ls_my_table -ZPASSWORD = 'initpass'.
ls_my_table -ZMY_FIELD1-ZAN_STRING = 'Sample'.
ls_my_table -ZMY_FIELD1-ZANOTHER_STRUCT-ZFIELD = 'NAME'.
ls_my_table -ZMY_FIELD1-ZANOTHER_STRUCT-ZVALUE = 'HERNAN'.
append ls_my_table to lt_my_table.
* inserting to database
insert ZMY_TABLE from table lt_my_table with accepting duplicate keys.
If sy-subrc ne 0.
Message 'Error while inseting data into zmy table' type 'E'.
Endif.Regards
Bhupal Reddy
2007 Jan 04 2:08 PM
Hi,
Please use following code.
data: lt_my_table type table of zmy_table.
ls_my_table type zmy_table.
ls_my_table -zuser = 'Test'.
ls_my_table -ZPASSWORD = 'initpass'.
ls_my_table -ZMY_FIELD1-ZAN_STRING = 'Sample'.
ls_my_table -ZMY_FIELD1-ZANOTHER_STRUCT-ZFIELD = 'NAME'.
ls_my_table -ZMY_FIELD1-ZANOTHER_STRUCT-ZVALUE = 'HERNAN'.
append ls_my_table to lt_my_table.
* inserting to database
insert ZMY_TABLE from table lt_my_table with accepting duplicate keys.
If sy-subrc ne 0.
Message 'Error while inseting data into zmy table' type 'E'.
Endif.Regards
Bhupal Reddy
2007 Jan 04 3:51 PM
Dear Bhupal,
Now I have another problem, I am publishing in the forums to give you points, but I am emailing you with my particular case with pictures. Look at this table:
Your code work with the field CONTROLLER because is a type table. But with the field ATRIBUTOS I got a problem because is a Deep Structure.
An this picture is the structure of field String
And this is my code:
DATA: ls_request TYPE STANDARD TABLE OF ZMMWS_GET_OBJECT_OOP_SOAP_IN.
wa_request like line of lt_request.
With this sentence I am getting the error: The type wa_request cannot be converted to An string
wa_request-ATRIBUTOS-STRING = 'An_String'.
So, I created the types:
types: BEGIN OF LINE_STRING,
string type string,
END OF LINE_STRING.
TYPES: BEGIN OF LINE_ZMMWS_ARRAY_OF_STRING,
controller type LINE_PRXCTRL,
string type LINE_STRING,
END OF LINE_ZMMWS_ARRAY_OF_STRING.
Data: TI_STRING TYPE STANDARD TABLE OF LINE_STRING,
TI_ZMMWS_ARRAY_OF_STRING TYPE STANDARD TABLE OFLINE_ZMMWS_ARRAY_OF_STRING,
WA_STRING LIKE LINE OF TI_STRING,
WA_STRING LIKE LINE OF TI_STRING.
Wa_string = An String.
WA_ZMMWS_ARRAY_OF_STRING-STRING = WA_STRING.
And I need to assign WA_ZMMWS_ARRAY_OF_STRING to wa_request-ATRIBUTOS
How Can I do it.
Thanks a lot,
Best & Regards,
Hernán Restrepo C
2007 Jan 04 4:37 PM
Hi,
Just assign the values to <internal table>-ZFIELD and -ZVALUE directly.
dirctly include the structure of the Z table.
data begin of itab.
include structure ZMY_FIELDS.
data end of itab.
try it!
Regards,
Aravind.