Wednesday, April 27, 2016

Write Tadir

The following program writes the essential information for workbench objects to the screen/spool.

report zjso_write_tadir.

tables tadir.

data gt_tadir type standard table of tadir.
data gs_tadir type tadir.

select-options so_pak  for tadir-devclass memory id dvc.
select-options so_onam for tadir-obj_name memory id obj_name.
select-options so_obj  for tadir-object memory id object.

start-of-selection.
  select from tadir into table gt_tadir where
    devclass in so_pak and
    object in so_obj and
    obj_name in so_onam.

  sort gt_tadir by object obj_name.

  loop at gt_tadir into gs_tadir.
    format color col_heading intensified.
    write/ gs_tadir-pgmidgs_tadir-objectgs_tadir-obj_name.
    format reset.

    case gs_tadir-object.
      when 'PROG'.
        perform write_prog using gs_tadir-obj_name.
      when 'CLAS'.
        perform write_clas using gs_tadir-obj_name.
      when 'TABL'.
        perform write_tabl using gs_tadir-obj_name.
      when 'DOMA'.
        perform write_doma using gs_tadir-obj_name.
      when 'DTEL'.
        perform write_dtel using gs_tadir-obj_name.
    endcase.
  endloop.

*&---------------------------------------------------------------------*
*&      Form  write_prog
*&---------------------------------------------------------------------*
form write_prog using iv_obj_name type sobj_name.

  data ls_trdir type trdir.
  data lt_prog_line type standard table of string.
  data lv_prog_line type string.
  data lt_textpool type standard table of textpool.
  data ls_textpool type textpool.
  data lv_string type string.

  format color col_heading intensified.
  select single from trdir into ls_trdir where name iv_obj_name.
  if sy-subrc 0.
    write/ ls_trdir.
    format reset.
  else.
    write'No TRDIR-Entry.'.
    format reset.
    uline.
*    exit.
  endif.

  read report iv_obj_name into lt_prog_line.
  read textpool iv_obj_name into lt_textpool.
*  select * from d020s into table lt_d020s where prog = iv_obj_name.

  skip.
  write'Source:' color col_heading .
  loop at lt_prog_line into lv_prog_line.
    if lv_prog_line is initial.
      skip.
    else.
      write/ lv_prog_line.
    endif.
  endloop.

  if lt_textpool[] is not initial.
    skip.
    write'Textpool:' color col_heading .
    loop at lt_textpool into ls_textpool.
      lv_string ls_textpool-entry.
      condense lv_string.
      write/ ls_textpool-idls_textpool-keyls_textpool-lengthlv_string.
    endloop.
  endif.

  uline.

endform.              "write_prog

*&---------------------------------------------------------------------*
*&      Form  write_clas
*&---------------------------------------------------------------------*
form write_clas using iv_obj_name type sobj_name.

  data lt_seocompo type standard table of seocompo.
  data lt_seoredef type standard table of seoredef.
  data ls_seocompo type seocompo.
  data ls_seoredef type seoredef.
  data lv_obj_name type sobj_name.

  write'Sections:' color col_heading intensified.

  lv_obj_name iv_obj_name.
* Public
  overlay lv_obj_name with '==============================CU'.
  perform write_prog using lv_obj_name.
* Protected
  lv_obj_name+30(2'CO'.
  perform write_prog using lv_obj_name.
* Private
  lv_obj_name+30(2'CI'.
  perform write_prog using lv_obj_name.


  write'Components:' color col_heading intensified.
  select from seocompo into table lt_seocompo where clsname iv_obj_name.
  sort lt_seocompo by cmptype cmpname.
  loop at lt_seocompo into ls_seocompo.
    write/ ls_seocompo.
  endloop.

  write'Redefined:' color col_heading intensified.
  select from seoredef into table lt_seoredef where clsname iv_obj_name.
  sort lt_seoredef by clsname mtdname.
  loop at lt_seoredef into ls_seoredef.
    write/ ls_seoredef.
  endloop.

  skip.

  loop at lt_seocompo into ls_seocompo.
    perform write_seocompo using ls_seocompo.
  endloop.

  loop at lt_seoredef into ls_seoredef.
    perform write_seoredef using ls_seoredef.
  endloop.

endform.                    "write_clas

*&---------------------------------------------------------------------*
*&      Form  write_seocompo
*&---------------------------------------------------------------------*
form write_seocompo using is_seocompo type seocompo.

  data lv_obj_name type sobj_name.

  write/ is_seocompo color col_heading .

  case is_seocompo-cmptype.
    when '0'"  Attribut
    when '1'"  Methode
      system-call query method is_seocompo-cmpname of class is_seocompo-clsname
        include into lv_obj_name no dblock.
      perform write_prog using lv_obj_name.
    when '2'"  Ereignis
    when '3'"  Typ
  endcase.

endform.                    "write_seocompo

*&---------------------------------------------------------------------*
*&      Form  write_seoredef
*&---------------------------------------------------------------------*
form write_seoredef using is_seoredef type seoredef.

  data lv_obj_name type sobj_name.

  write/ is_seoredef color col_heading .

  system-call query method is_seoredef-mtdname of class is_seoredef-clsname
    include into lv_obj_name no dblock.
  perform write_prog using lv_obj_name.

endform.

*&---------------------------------------------------------------------*
*&      Form  write_tabl
*&---------------------------------------------------------------------*
form write_tabl
  using
    iv_db_table type sobj_name.

  data lt_ddic_field type ddfields.
  data ls_ddic_field type dfies.
  data lo_tdesc type ref to cl_abap_typedescr.
  data lo_sdesc type ref to cl_abap_structdescr.
  data lv_ddobjname type ddobjname.
* Header of tables with short text
  data ls_dd02v type dd02v.
* Foreign Key Fields of Table
  data ls_dd08v type dd08v.
  data lt_dd08v type standard table of dd08v.
* Indexes
  data ls_dd17v type dd17v.
  data lt_dd17v type standard table of dd17v.

  call method cl_abap_structdescr=>describe_by_name
    exporting
      p_name         iv_db_table
    receiving
      p_descr_ref    lo_tdesc
    exceptions
      type_not_found 1
      others         2.

  check sy-subrc 0.
  lo_sdesc ?= lo_tdesc.

  lv_ddobjname iv_db_table.
  call function 'DDIF_TABL_GET'
    exporting
      name          lv_ddobjname
      langu         sy-langu
    importing
      dd02v_wa      ls_dd02v
    tables
      dd08v_tab     lt_dd08v
      dd17v_tab     lt_dd17v
    exceptions
      illegal_input 1
      others        2.

  check sy-subrc 0.

* Write Header
  format color col_heading.
  write/ iv_db_tablels_dd02v-ddtextls_dd02v-tabclass.
  format reset.

* Write Fields
  lt_ddic_field lo_sdesc->get_ddic_field_list).
  sort lt_ddic_field by tabname position.

  format color col_heading.
  write/'Fields'(010).
  write/
    'Key'(011),
    'Fieldname                     '(012),
    'Data Element                  '(013),
    'Text                    '(014),
    'Type      ',
    'Length',
    'Decim.'.
  format reset.

  loop at lt_ddic_field into ls_ddic_field .
    write/
      ls_ddic_field-keyflag' ',
      ls_ddic_field-fieldname(30),
      ls_ddic_field-rollname(30),
      ls_ddic_field-scrtext_l(24),
      ls_ddic_field-datatype,
      ls_ddic_field-leng,
      ls_ddic_field-decimals.


  endloop.

* Write Foreign Key Fields
  if lt_dd08v[] is not initial.
    format color col_heading.
    write/'Foreign Key Fields'(015).
    write/
      'Fieldname       '(012),
      'Checktable      '(016).
    format reset.
    loop at lt_dd08v into ls_dd08v.
      write/
        ls_dd08v-fieldname(16),
        ls_dd08v-checktable(16).
    endloop.
  endif.

* Write Indexes
  if lt_dd17v[] is not initial.
    sort lt_dd17v by sqltab indexname position.
    format color col_heading.
    write/'Indexes'(017).
    write/
      'Table Name          '(018),
      'Index       '(019),
      'Field       '(020).
    format reset.
    loop at lt_dd17v into ls_dd17v.
      write/
        ls_dd17v-sqltab(20),
        ls_dd17v-indexname(3)'        ',
        ls_dd17v-fieldname(12).
    endloop.
  endif.

  uline.

endform.                    "document_db_table

*&---------------------------------------------------------------------*
*&      Form  write_doma
*&---------------------------------------------------------------------*
form write_doma using iv_doma type sobj_name.

  data lv_ddobjname type ddobjname.
  data ls_dd01v type dd01v.
  data lt_dd07v type standard table of dd07v.
  data ls_dd07v type dd07v.

  lv_ddobjname iv_doma.
  call function 'DDIF_DOMA_GET'
    exporting
      name          lv_ddobjname
      langu         sy-langu
    importing
      dd01v_wa      ls_dd01v
    tables
      dd07v_tab     lt_dd07v
    exceptions
      illegal_input 1
      others        2.

  check sy-subrc 0.

  format color col_heading.
  write/
    'Type      ',
    'Length',
    'OutLen',
    'Decim.',
    'L',
    'S'.
  format reset.

  write/
    ls_dd01v-datatype,
    ls_dd01v-leng,
    ls_dd01v-outputlen,
    ls_dd01v-decimals,
    ls_dd01v-lowercase,
    ls_dd01v-signflag.

  if lt_dd07v[] is not initial.
    format color col_heading.
    skip.
    write'Fixed Values'.
    format reset.

    loop at lt_dd07v into ls_dd07v.
      write/
        ls_dd07v-valpos,
        ls_dd07v-ddlanguage,
        ls_dd07v-domvalue_l,
        ls_dd07v-domvalue_h,
        ls_dd07v-ddtext,
        ls_dd07v-domval_ld,
        ls_dd07v-domval_hd.
    endloop.
  endif.

  uline.
endform.                    "write_doma

*&---------------------------------------------------------------------*
*&      Form  write_dtel
*&---------------------------------------------------------------------*
form write_dtel using iv_dtel type sobj_name.

  data lv_ddobjname type ddobjname.
  data ls_dd04v type dd04v.

  lv_ddobjname iv_dtel.
  call function 'DDIF_DTEL_GET'
    exporting
      name          lv_ddobjname
      langu         sy-langu
    importing
      dd04v_wa      ls_dd04v
    exceptions
      illegal_input 1
      others        2.

  check sy-subrc 0.

  format color col_heading.
  write/
    'Text                                                        ',
    'Domain name                   ',
    'OutLen',
    'Mem.ID              ',
    'L',
    'Datatype  ',
    'Length',
    'Decim.'.
  format reset.

  write/
    ls_dd04v-ddtext,
    ls_dd04v-domname,
    ls_dd04v-routputlen,
    ls_dd04v-memoryid,
    ls_dd04v-logflag,
    ls_dd04v-datatype,
    ls_dd04v-leng,
    ls_dd04v-decimals.

  format color col_heading.
  write/
    'Texts'.
  format reset.
  write/ ls_dd04v-headlenls_dd04v-reptext.
  write/ ls_dd04v-scrlen1ls_dd04v-scrtext_s.
  write/ ls_dd04v-scrlen2ls_dd04v-scrtext_m.
  write/ ls_dd04v-scrlen3ls_dd04v-scrtext_l.

  uline.
endform.                    "write_doma

No comments:

Post a Comment

SAP ABAP: Determine Timezone for Plant

    DATA:       lt_tzone TYPE STANDARD TABLE OF tznzone WITH DEFAULT KEY,       l_tzone  TYPE tznzone.     " get time zone for plant   ...