Deep DDIC-Structure - Method to get the Comp.Type of a sub-structure

Dear colleagues,
thought the subsequent piece of coding might be helpful for the following problem:
In DDIC you have created a deep/nested Structure e.g. a complete Business Document representation like
s_doc_header type struct_doc_header
     (incl.) item  type tab_item
        (incl) party type tab_party etc.
Now for some purpose you need to access somewhere a sub-part of this structure, e.g. the party-part. You only know (dynamically) the component name "party", but need for dynamic access also the Component Type ("tab_party") (in order to make use of  a "CREATE DATA lr_reftodata TYPE (determined_comp_type)." )
The following piece of coding should help to query any start component type (here "struct_doc_header") for its embedded components.
Its a recursive use of features provided by the very nice class(set) of cl_abap_structdescr.
I implemented it as a static method.
When doing so, you need to ensure, that the TYPE-GROUP "ABAP" is linked to the class (class properties --> forward declarations),
Let me know if you find it useful.
And apologies in advance, if the same problem was already posted in the forum. I did only a rough search before due to a lag of ideas for appropriate search-strings ...
Best regards,
Rudy
Signature:
Importing:
IV_COMPNAME     TYPE ABAP_COMPNAME
IV_START_STRUCTR     TYPE KOMP_TYPE
Exporting/returning
EV_DDIC_STRUCT     TYPE KOMP_TYPE
METHOD search_deep_ddic_by_comp.
* Description      -------------------------------------------
*  Methods looks into a deep DDIC-Structure and returns the
*  corresponding TYPE
*  Prerequsite for usage: Structures component names are unique.
* Local Data Defintions --------------------------------------
* Locals -----------------------------------------------------
* TYPES:
  DATA: lv_compname                 TYPE abap_compname.
  DATA: lt_componenttable           TYPE abap_component_tab.
  DATA: lv_relative_name            TYPE string.
  DATA: lv_ddic_header                  TYPE x030l.
  DATA: lv_ddic_struct              TYPE komp_type.
  DATA: lv_start_struct             TYPE komp_type.
* supporting
  DATA: lv_lines                    TYPE i.
  DATA: lv_message                  TYPE string.
  DATA: lt_selopt                   TYPE sesf_selection_parameters_tab.
  DATA: ls_selopt                   TYPE sesf_selection_parameter.
* References -------------------------------------------------
  DATA: lo_struct_descr             TYPE REF TO cl_abap_structdescr.
  DATA: lo_type_descr               TYPE REF TO cl_abap_typedescr.
* Field-Symbols ----------------------------------------------
  FIELD-SYMBOLS:
        <fs_struct_descr_component> TYPE abap_componentdescr.
  lo_struct_descr ?= cl_abap_structdescr=>describe_by_name( p_name = iv_start_structr ).
  IF lo_struct_descr IS BOUND.
*   get all sub-structures/components of iv_start_structr
    CALL METHOD lo_struct_descr->get_components
      RECEIVING
        p_result = lt_componenttable.
    lv_compname = iv_compname.
    READ TABLE lt_componenttable ASSIGNING <fs_struct_descr_component>
                                           WITH KEY  name = lv_compname.
    IF sy-subrc = 0.
*     matching component found - search for DDIC structure
      CALL METHOD <fs_struct_descr_component>-type->get_relative_name
        RECEIVING
          p_relative_name = lv_relative_name.
      ASSERT lv_relative_name IS NOT INITIAL.
      CASE <fs_struct_descr_component>-type->type_kind.
        WHEN 'u' OR 'v'. "structure
          ev_ddic_struct = lv_relative_name.
          RETURN.
        WHEN 'h'. "table type - derive the line type
          lo_type_descr ?= cl_abap_datadescr=>describe_by_name( p_name = lv_relative_name ).
          CALL METHOD lo_type_descr->get_ddic_header
            RECEIVING
              p_header = lv_ddic_header.
          IF sy-subrc = 0.
            ev_ddic_struct   = lv_ddic_header-refname.
            RETURN.
          ELSE.
            "error
          ENDIF.
        WHEN OTHERS.
          "error
      ENDCASE.
    ELSE.
*     go deeper into structure and look into each sub-structure via recursion
      LOOP AT lt_componenttable ASSIGNING <fs_struct_descr_component>.
        CALL METHOD <fs_struct_descr_component>-type->get_relative_name
          RECEIVING
            p_relative_name = lv_relative_name.
        ASSERT lv_relative_name IS NOT INITIAL.
        CASE <fs_struct_descr_component>-type->type_kind.
          WHEN 'u' OR 'v'. "structure
          WHEN 'h'. "table type - derive the line type
            lo_type_descr ?= cl_abap_datadescr=>describe_by_name( p_name = lv_relative_name ).
            CALL METHOD lo_type_descr->get_ddic_header
              RECEIVING
                p_header = lv_ddic_header.
            IF sy-subrc = 0.
              lv_relative_name = lv_ddic_header-refname.
            ELSE.
              "error
            ENDIF.
          WHEN OTHERS.
            EXIT. "next loop, investigate only struct and table
        ENDCASE.
*        lv_compname     = <fs_struct_descr_component>-name.
        lv_start_struct = lv_relative_name.
        CALL METHOD /scmtms/cl_ddic_utility=>search_deep_ddic_by_comp
          EXPORTING
            iv_compname      = iv_compname
            iv_start_structr = lv_start_struct
          IMPORTING
            ev_ddic_struct   = lv_ddic_struct.
        IF lv_ddic_struct IS NOT INITIAL.
          ev_ddic_struct = lv_ddic_struct.
          EXIT.
        ENDIF.
      ENDLOOP.
    ENDIF.
  ENDIF.
ENDMETHOD.

Using command:
ASSIGN COMPONENT idx OF STRUCTURE struc TO <fs>.
For example:
DESCRIBE FIELD pi_output TYPE pi_output COMPONENTS lv_columns. "For number of columns
DO lv_columns TIMES.
ASSIGN COMPONENT SY-INDEX OF
STRUCTURE (name of structure) TO <l_fs_output>. "<l_fs_output> - field of structure
DESCRIBE FIELD <l_fs_output>... "with other options.
ENDDO.

Similar Messages

  • Method to Get the INPUT parameter CONTENT byte length

    method to get the INPUT parameter CONTENT byte length

    Dear "clown of forums",
    Please read the forum rules and ask understandable questions -> one thread per properly formulated question after having searched.
    Thread locked.

  • How to get the Database type from weblogic Db connection

    I want to use database version control in my application . that means different database type use different Sql Statement. Such as in weblogic7.0 if I create SqlServer JDBC pool then I will use some special Sqlserver sql Statement . such as some join statement. If I create Oralce JDBC pool then I have to use different Sql statement . because these two database support different Sql statement.
    What my question is how to get the database type from the connection.

    For a normal jdbc driver you can use
    Connection.getMetaData()
    To get the meta data, in particular the getDatabase...() methods.
    That might or might not work.
    However, at the very least in the server you have access to the weblogic properties so you can parse the pool property to figure it out.

  • Getting the object type of a Table

    Hi,
    I'm trying to get metadata out of my database and am using the various features of getMetaData() etc to get most of the information I need.
    The only problem I have is that I can't get the actual types of the tables in my database.
    For example I have the Table Lecturers which is of TYPE Lecturer.
    I can get the actual name of the table back by querying the db, but I can't get the actual type of it i.e. Lecturer!
    Does anyone know of a function (or any method at all) that will do this for me in Java ?
    Hope Someone can help me,
    Best Regards,
    Finian.
    Ps I'm using Oracle 9i and the Oracle thin Jdbc driver to connect to it.

    if i dont want any thing but data on the target database.
    i am thinkink about using exclude parameter on indexes,triggers,constraints,views,functions,prodecures,packages. this is how my parameter file will look for import.....
    DIRECTORY=IMP_USAC_DIR
    DUMPFILE=slcu.dmp
    SCHEMAS=slc
    EXCLUDE=ref_constraint
    EXCLUDE=index
    EXCLUDE=view
    EXCLUDE=function
    EXLUDE=trigger
    EXCLUDE=procedure
    EXCLUDE=package
    EXCLUDE=sequence
    LOGFILE=slcutest.log
    Let me know if this will work
    Thanks
    Message was edited by:
    mtaji wa maskini

  • How to get the Data type of the Internal Table.

    How can i get the data types used to create an internal table
    TYPES : BEGIN OF t_makt,
              matnr    TYPE    matnr,
              maktx    TYPE    maktx,
            END OF t_makt.
    Like this some function will give me which data types i have used for the internal table at run time.

    Use the FM ..
    data : int_fcat type SLIS_T_FIELDCAT_ALV.
    REUSE_ALV_FIELDCATALOG_MERGE ..
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                I_PROGRAM_NAME         = sy-repid
                I_INTERNAL_TABNAME     = 'IMAT'   <-- this is your internal table
                 I_INCLNAME             = sy-repid
           CHANGING
                CT_FIELDCAT            = int_fcat <--- this contains all the fields along with their characteristics ...
           EXCEPTIONS
                INCONSISTENT_INTERFACE = 1
                PROGRAM_ERROR          = 2
                OTHERS                 = 3.

  • [CS3][JS] How to get the file type of current document

    Hi,
    How to get the file type of current opening document (e.g., tif, jpeg, png) using JavaScript with Photoshop CS3.
    I am using file object the open the files one by one in the folder (the files sometimes don't have the extensions).
    If the current document is in tiff format then I need to convert to 8-bit, if its an Jpg image then needs to ignore the file.
    Regards,
    Karthik

    Do you really need to know the file type? What about just checking the bit depth?
    var doc = activeDocument;
    if (doc.bitsPerChannel != BitsPerChannelType.EIGHT) {//Not 8 bit
    doc.bitsPerChannel = BitsPerChannelType.EIGHT;
    //do your save etc
    }else{
        //Ignore

  • How to get the MIME type of the given file in R/3

    Dear Experts,
    Please tell me the FM or Class to get the given file MIME type in R/3 . I am using GUI_upload Function module to upload the file in R/3 .
    Edited by: balaji ramadas on Jan 16, 2009 5:39 AM

    Thank you Prosenjit I m using this FM   CV120_GET_MIME_TYPE
    to get the MIME type of the file
    regards,
    Balaji.R
    Edited by: balaji ramadas on Jan 19, 2009 9:24 AM

  • How I can get the Billing Type for the sales order and its items

    How I can get the Billing Type for the sales order and its items. I mean from which SAP tables and how?

    Hi,
    You need to use two tables.
    First use VBFA. Enter the sales order number in the field Predecessar and the value M in SubCt field. This will give all the billing document number for the sales order items.
    Then use the billing document numbers in table VBRK, where in you can get the billing document type.
    Regards,

  • How to get the document type, name and revision from the search page cv04n

    Hello,
    After performing cv04n and getting a list of documents satisfying the search criteria, how can I then get the document type, name and revision of the selected document using ABAP?
    Thanks

    HI,
    IN table DRAW... u have Document type, Version and document number.
    In Table DRAT also u get Document Type, Version, Number and Description of Doucment.
    Regards
    SAB

  • Getting the file type from a placed file

    Hi
    I am trying to get the file type from items placed on a page. I know the types available has one of the three interfaces "IImageAttributes", "IEPSAttributes" or "IPDFAttributes", but how can i test whether the placed image is a TIF, JPG ... Of course i could test on the suffix or the file type (mac), but that isnt "secure" enough, since InDesign can place files with no filetype or extension, if they are in an importable format.
    What I want in short, is to read the filetype shown in the Info palette, any one knows how to do this?
    Jon

    Thanks, I did take a look in these interfaces, but that didnt solve the problem for eps, pdf and other none raster types.
    Instead I found the:
    IDataLink->GetNameInfo()
    Which gives me the string from the Info palette.

  • How do i get the material type after submitting a create material request?

    Hi All,
    I have to select an agent depending on the material type of the material being created? I'm not using the rule based workflow for material creation in MDG 7.0, I'm using WS46000057. How do I get the material type being used in the workflow so that I can create a rule and select an agent accordingly from a custom table.
    Any kind of help would be sincerely appreciated.
    Regards,
    Tushar..

    Why not use the rule-based workflow template?
    Where do you want the material type? This is a standard workflow template and I'm not sure you can enhance it.
    In any case, in order to read CR details, you need to use the MDG API classes. These are described in this document: Master Data Governance Application Programming Interface Guide. Keep in mind that different API classes were developed for different releases so make sure to pick the class right for your release.

  • Is there any function module getting the cpu type?

    Is there any function module getting the cpu type?

    I guess the database server...
    I would like to get the SAP system cpu type as done in transaction st06 under system information.
    Thanks.

  • How to get the mime type of the workflow attachment attached to workitem id

    Hi Experts,
    I can attach different types of attachment to the workitem id, lets suppost the attachment type attached is pdf, for this attachment I have an requirement to send the mime type as well. In this case the mime type is 'application/pdf' for pdf files.(for text file it is 'text/plain' and for zip file it is 'application/zip' and so on)
    Do I have any place in ABAP world where I can get the mime type for different types of attachments.
    I dont want to hard code the mime types, and I have checked the transaction 'SMW0', but not sure if this is the correct place to get the mime type.
    Do you see any other way or tables which stores all these mime types.
    Any help/suggestion would be appreciated.
    Thanks and Regards,
    Neerup.

    Hello,
    Perhaps this can help:
    http://help.sap.com/saphelp_nw04/helpdata/en/ad/ebe5cc1d75aa43a2871717d76f475d/content.htm
    If you want to know the table name, turn on tracing (ST05) when accessing the MIME types.
    regards
    Rick Bakker
    Hanabi Technology

  • How to get the icon type of a JTree node, very urgent

    hi,
    i need to get the type of a JTree node but don't know how. this is quite an emergency. please help. thank you all.
    -joey

    there are several icons defined in the DefaultTreeCellRenderer class, such as closedIcon, leafIcon, openIcon. i was wondering if there is any way to get the icon type of a node. thanks for your reply.
    -joey

  • How to get the order type from notification number

    Hi,
    i have the notification number,
    fromthis number how can i get the Maintenance Order type.
    what is the table name to get the order type.
    Please tell me.

    Hi,
    First you read table QMEL with notification number and get AUFNR. Then go to AUFK and get AUART (order type).
    Some thing like,
    SELECT SINGLE aufnr INTO lv_aufnr FROM qmel WHERE qmnum EQ <your notification>.
    IF sy-subrc EQ 0 AND NOT lv_aufnr IS INITIAL.
      SELECT SINGLE auart INTO lv_auart FROM aufk WHERE aufnr EQ lv_aufnr.
    ENDIF.
    Hope this helps..
    Sri

Maybe you are looking for