Form itabtodataset tables intab Using dname type C. Data: TAB type X value '09 ', Enter (2) Type X value '0d0a ', Count (8) type N. Data: Begin of headtab occurs 0, Length type I, Decimals type I, Type_kind type C, Name (30) type C, End of headtab. Data N type I. Data descr_ref type ref to cl_abap_structdescr. Field-Symbols: <comp_wa> type abap_compdescr, <F_field>, <F_intab> type any. Data: Str type string, Text1 type C. Data: runtime type int4, Repid like sy-repid. Data: FLEN type I. Field-Symbols: <dyn_table> type standard table, <Dyn_wa>, <Dyn_field>. Data: dy_table type ref to data, Dy_line type ref to data, Xfc type lvc_s_fcat, IFC type lvc_t_fcat. Descr_ref? = Cl_abap_typedescr => describe_by_data (intab ). Loop at descr_ref-> components assigning <comp_wa>. Move-corresponding <comp_wa> to headtab. Append headtab. Endloop. Loop at headtab. FLEN = FLEN + headtab-Length + headtab-Decimals + 1. Endloop. Clear xfc. Xfc-fieldname = 'line '. Xfc-datatype = 'Char '. "Or xfc-inttype = 'C '. Xfc-intlen = FLEN. Append xfc to IFC. Call method cl_alv_table_create => create_dynamic_table Exporting It_fieldcatalog = IFC Importing Ep_table = dy_table. Assign dy_table-> * to <dyn_table>. Create data dy_line like line of <dyn_table>. Assign dy_line-> * to <dyn_wa>. Assign component 'line' of structure <dyn_wa> to <dyn_field>. Describe table headtab lines n. Loop at intab assigning <f_intab>. Do n times. Assign component sy-index of structure <f_intab> to <f_field>. STR = <f_field>. Read Table headtab index sy-index. If headtab-type_kind = 'I' or headtab-type_kind = 'P' Or headtab-type_kind = 'F '. Search STR '-'. If sy-subrc = 0 and sy-fdpos <> 0. Split STR at '-' into STR text1. Condense Str. Concatenate '-'str into Str. Else. Condense Str. Endif. Else. * Shift STR Left deleting leading '0 '. Endif. Concatenate <dyn_field> tab STR into <dyn_field>. Enddo. Shift <dyn_wa>. Append <dyn_wa> to <dyn_table>. Clear <dyn_wa>. Count = count + 1. Endloop. Open dataset dname for output in binary mode. If sy-subrc Ne 0. Endif. Loop at <dyn_table> into <dyn_wa>. STR = <dyn_wa>. Transfer STR to dname. Transfer enter to dname. Endloop. Close dataset dname. Endform. |