Advertisement
CDLG_TGR

Affichage champs valeurs table dynamique

Apr 19th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1.  
  2. FORM display_entries
  3. USING
  4. it_tbllin TYPE tt_tbllindup
  5. it_tblkey TYPE tt_tblflddup
  6. it_tblfld TYPE tt_tblflddup.
  7.  
  8. DATA : ls_tbllin TYPE ts_tbllindup.
  9.  
  10. FIELD-SYMBOLS : <fs_tbl> TYPE ANY TABLE,
  11. <fs_str> TYPE any,
  12. <fs_fld> TYPE any.
  13.  
  14. DATA : lcl_table TYPE REF TO cl_abap_tabledescr,
  15. lcl_struc TYPE REF TO cl_abap_structdescr,
  16. it_field TYPE abap_compdescr_tab,
  17. ls_field TYPE abap_compdescr.
  18.  
  19. DATA : ls_tblfld TYPE ts_tblflddup.
  20.  
  21. DATA : ls_line TYPE REF TO data.
  22.  
  23.  
  24. LOOP AT it_tbllin INTO ls_tbllin.
  25. FORMAT HOTSPOT ON.
  26. WRITE :/10(20) ls_tbllin-tabname.
  27. FORMAT HOTSPOT OFF.
  28. ASSIGN ls_tbllin-entries->* TO <fs_tbl>.
  29. CREATE DATA ls_line LIKE LINE OF <fs_tbl>.
  30. ASSIGN ls_line->* TO <fs_str>.
  31.  
  32. lcl_table ?= cl_abap_typedescr=>describe_by_data( <fs_tbl> ).
  33.  
  34. * Get the table line type i.e., structure details
  35. lcl_struc ?= lcl_table->get_table_line_type( ).
  36.  
  37. * Get the components(fields) of the table line
  38. it_field = lcl_struc->components.
  39.  
  40. LOOP AT <fs_tbl> INTO <fs_str>.
  41. LOOP AT it_field INTO ls_field.
  42. FORMAT INTENSIFIED ON.
  43. WRITE /30(20) ls_field-name.
  44. FORMAT INTENSIFIED OFF.
  45. ASSIGN COMPONENT ls_field-name
  46. OF STRUCTURE <fs_str> TO <fs_fld>.
  47. WRITE 60(20) <fs_fld>. " valeur actuelle
  48. READ TABLE it_tblkey WITH KEY tabname = ls_tbllin-tabname
  49. fieldname = ls_field-name INTO ls_tblfld.
  50. IF sy-subrc EQ 0.
  51. WRITE 90(20) ls_tblfld-newvalue. " nouvelle valeur
  52. ENDIF.
  53.  
  54. READ TABLE it_tblfld WITH KEY tabname = ls_tbllin-tabname
  55. fieldname = ls_field-name INTO ls_tblfld.
  56. IF sy-subrc EQ 0.
  57. WRITE 90(20) ls_tblfld-newvalue. " nouvelle valeur
  58. ENDIF.
  59.  
  60.  
  61. ENDLOOP.
  62. SKIP 1.
  63. ENDLOOP.
  64.  
  65. ENDLOOP.
  66. ENDFORM.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement