2006 Jun 02 12:35 PM
Hello
i have a structure A with 3 fields.
- Field A is of type DATS length 8.
- FIELD B is of type DEC length 5.
- FIELD C is of type CHAR length 7.
The problem is with datatypes of DATS the internal value is '0000000' when the value is initial.
Now i need to move the entries of the structure A to a structure B with 3 fields as well
- FIELD A is of type CHAR length 8.
- FIELD B is of type CHAR length 5.
- FIELD C is of type CHAR length 7.
I do have 2 problems now:
1.) when the value field A of structure A is emtpy, 0000000 gets move to field A of structure B. This shouldnt happen, or at least i need to clear it afterwards.
2.) When the value of field A of structure is not emtpy, the internal date format yyyymmdd gets moved to field A of structure b and not the extrenal layout.
Anyone has an idea how to solve the problem?
regards,
Markus
When the data is empty in these fields they have the internal value of '00000000'. Now i do want to
2006 Jun 02 12:43 PM
Hi markus,
1. Instead of using
field1 = field2,
2. u can use
WRITE field1 to field2.
regards,
amit m.
Hi markus,
1. Instead of using
field1 = field2,
2. u can use
WRITE field1 to field2.
regards,
amit m.
2006 Jun 02 12:41 PM
2006 Jun 02 12:41 PM
1 and 2. Move the fieldA of Structure A to fieldA of structure B only when it is not initial.
Declare the fieldA as CHAR 10 to accomodate the external date format..
if not structureA-fieldA is initial.
write structureA-fieldA to structureB-fieldA.
endif.
2006 Jun 02 12:43 PM
Have temporary intermediate variable of char type.
tempa(8).
tempa = a.
if tempa = '00000000'.
translate tempa using '0 '.
endif.
final_a = tempa.
Regards,
ravi
2006 Jun 02 12:43 PM
Hi markus,
1. Instead of using
field1 = field2,
2. u can use
WRITE field1 to field2.
regards,
amit m.
2006 Jun 02 12:52 PM
Thx all for the reply, but i do want it to have it more dynamically.
Kinda loop over the components of structre A and B and assign dependent of the type the data.
2006 Jun 02 12:58 PM
2006 Jun 02 1:30 PM
Hi
FIELD-SYMBOLS: <FS_A> TYPE ANY,
<FS_B> TYPE ANY.
DO 3 TIMES.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE A TO <FS_A>.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE B TO <FS_B>.
IF NOT <FS_A> IS INITIAL.
MOVE <FS_A> TO <FS_B>.
ENDIF.
ENDDO.
Max
2006 Jun 02 1:35 PM
Soo i got it working:
This is my code:
lo_type = cl_abap_structdescr=>describe_by_name( structure_A ).
lo_struc ?= lo_type.
lt_ddfields_A = lo_struc->get_ddic_field_list( p_including_substructres = 'X' ).
free lo_type. free lo_struc.
lo_type = cl_abap_structdescr=>describe_by_name( structure_B ).
lo_struc ?= lo_type.
lt_ddfields_B = lo_struc->get_ddic_field_list( p_including_substructres = 'X' ).
loop at lt_data into ls_data.
loop at lt_ddfields_B into ls_ddfields_B.
loop at lt_ddfields_A into ls_ddfields_A where fieldname = ls_ddfields_B-fieldname.
concatenate 'ls_data-' ls_ddfields_A-fieldname into l_field_A.
condense l_field_A no-gaps.
assign (l_field_A) to <field_A>.
concatenate 'ls_data-' ls_ddfields_A-fieldname into l_field_B.
condense l_field_B no-gaps.
assign (l_field_B) to <field_B>.
<field_B> = <field_A>.
if ls_ddfields_A-datatype = 'DATS' and <field_B> = '00000000'.
clear <field_B>.
elseif ls_ddfields_A-datatype = 'DATS' and not <field_B> = '00000000'.
call function 'CONVERSION_EXIT_MODAT_OUTPUT'
exporting
input = <field_B>
importing
output = <field_B>.
endif.
endloop.
endloop.
append ls_data to lt_data.
endloop.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |