‎2009 Feb 23 5:08 AM
Hii All,
I am in to a serious trouble it is as follows.
I have a Z table from which i will be getting a field name and from a idoc i will be getting a value in a segment.
I have to update a table with the value from the idoc into the field name which i have retrieved from the Z table.
Now based on the select the field name will be changing everytime based on select query.
Now how do i modify the Database table??? since the field is changing everytime.
I tried using the field symbols but it is not working.
it is not allowing me to wrote say W_itab-<FS> = idoc-value.
PLEASE HELP ME OUT.
Thanks,
Ravindra.
‎2009 Feb 23 5:36 AM
Hi Ravindra,
Try the following code:
create a varable of type string.
DATA: lv_condition TYPE string.
Now as you said you have the name of the variable from the IDOC. So use a concatenate statement to create a UPDATE condition. Somewhat like this:
CONCATENATE idoc-field ' = ' idoc-value INTO lv_condition.
UPDATE ztable
set (lv_condition).
This was one of the ways.....
Hope this helps.
Regards,
Prakash Pandey
‎2009 Feb 23 5:24 AM
Hi Ravindra,
Can you paste your code for updating the Z table here?
Regards,
Prakash Pandey
‎2009 Feb 23 5:31 AM
Hi ravindra ,
You declare one generic structure with all the fields which are included in your select query.move corresponding values from field symbol to this structure. now easily u can update the table with the fields.The fields which will contains value will be updated and the remainig field which does not contain value will be empty.
like....
* Generic structure with the required fields (or) all the fields from the table
TYPES:
BEGIN OF TYPE_S_GENERIC,
KDGRP TYPE KDGRP,
KUNNR TYPE KUNNR,
MATNR TYPE MATNR,
DATBI TYPE DATBI,
DATAB TYPE DATAB,
KNUMH TYPE KNUMH,
END OF TYPE_S_GENERIC.
* * Select the records from table
SELECT *
FROM (WA_ALL_TABS-TABNAME)
INTO TABLE <ITAB>
WHERE (W_CONDITION)
AND KAPPL EQ PR_KAPPL
AND KSCHL EQ PR_KSCHL.
IF SY-SUBRC EQ 0.
CREATE DATA REF_WA LIKE LINE OF <ITAB>.
ASSIGN REF_WA->* TO <FS_WA>.
LOOP AT <ITAB> INTO <FS_WA>.
MOVE-CORRESPONDING <FS_WA> TO WA_GENERIC.
APPEND WA_GENERIC TO T_GENERIC.
endloop.
ENDIF.Regards,
Rajitha.
‎2009 Feb 23 5:40 AM
Hii
Here are the values in the ztable.
Z_VC_MY
Z_VC_MODEL
Z_VC_MARKET
Z_VC_DESTINATION
Z_VC_COLOR
Z_VC_ABS
Z_VC_WHEEL
Now in these values and the fields in some other table.
now every time in the select i will get some field name say in one case it is "Z_VC_WHEEL"
Now in the work area i need to update Z_VC_WHEEL field with the value i am getting in the IDOC.
and modify the data base table from the work area.
Thanks,
Ravindra.
‎2009 Feb 23 5:48 AM
Hi Ravindra,
Above given example is for a simple report. You can also do like that. If the work area contains only
Z_VC_WHEEL value and you want to updat with that value. Then the value will be updated with this field and make other fields remains same for that record.
Regards,
Rajitha.
‎2009 Feb 23 5:51 AM
Hi Ravindra,
If you already have the values in the work area then I have another way to solve your problem.
use the following statement.
ASSIGN COMPONENT 'Z_VC_WHEEL' OF STRUCTURE work_area to <fs_any>.
CHECK <fs_any> IS ASSIGNED.
<fs_any> = idoc-value.
Now you can update the database from your work area.
Regards,
Prakash Pandey
‎2009 Feb 23 5:52 AM
Hi Ravindra,
If you already have the values in the work area then I have another way to solve your problem.
use the following statement.
ASSIGN COMPONENT 'Z_VC_WHEEL' OF STRUCTURE work_area to <fs_any>.
CHECK <fs_any> IS ASSIGNED.
<fs_any> = idoc-value.
Now you can update the database from your work area.
Regards,
Prakash Pandey
‎2009 Feb 23 8:00 AM
Thank you very much Rajitha Sangi and Prakash Pandey
Thanks,
Ravindra
‎2009 Feb 23 5:36 AM
Hi Ravindra,
Try the following code:
create a varable of type string.
DATA: lv_condition TYPE string.
Now as you said you have the name of the variable from the IDOC. So use a concatenate statement to create a UPDATE condition. Somewhat like this:
CONCATENATE idoc-field ' = ' idoc-value INTO lv_condition.
UPDATE ztable
set (lv_condition).
This was one of the ways.....
Hope this helps.
Regards,
Prakash Pandey