Skip to Content
avatar image
Former Member

Function - dynamic export parameter

Hello experts,

I have several similar ODSs objects, i would like to read their content (export paramater = structure of the ODS), but i don't want to create the function for every ODS. Is it possible set up export parameter as dynamic or do you have another solution ?

Thanks for advice in advance

Martin

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Aug 20, 2007 at 10:30 AM

    declare the import parameter as type ref to DATA

    in the program calling the FM first fill this itab with data .

    data: itab type <ODSNAMETABLENAME> .

    data: odstab type ref to data .

    *fill data to itab

    get reference of itab into odstab .

    now pass this odstab to the FM import parameter (which of type ref to data)

    in this approach only the program which is calling the FM whould know the odstable name in design time. this can also be avoided by dynamically creating the itab.

    within the FM code you can have the following code to convert the type ref to DATA vairalbe to a itab.

    field-symbols: <outtab> type any table .

    assign var->* to <outtab> . (where var is the import parameter name which is of type ref to DATA)

    Hope this is clear.

    Sorry, didnt read the question carefully and missed that you want it as export parameter. you can use similar approach for export param as well

    Regards

    Raja

    Message was edited by:

    Durairaj Athavan Raja

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      thanks a lot, but I have one small problem.

      I received an error if i use some Key Figure (e.g. 0ACC_QTY) in the table - error icompatible fields.

      I can see in the table definition length(17) and decim. places 3 for KF, but in the line of program (debug) , i see

      xfc-intlen = xdetails-length. - > 9

      xfc-decimals = xdetails-decimals.- > 3

      Do you have any idea ?

      Thanks Martin

  • avatar image
    Former Member
    Aug 20, 2007 at 10:55 AM

    Hi

    You can try the following approach.

    Lets assume your ODS structure which bring the data is XTH_DATA.

    ***Creating Dynamic internal table of type XTH_DATA.***

    DATA : LT_RESULT_D TYPE REF TO DATA.

    **If the incoming table is hashed type**

    FIELD-SYMBOLS : <LT_RESULT> TYPE HASHED TABLE. "

    CREATE DATA: LT_RESULT_D LIKE XTH_DATA.

    **Creating Dynamic work area**

    DATA: L_REC_D TYPE REF TO DATA.

    FIELD-SYMBOLS: <L_REC> TYPE ANY.

    CREATE DATA: L_REC_D LIKE LINE OF XTH_DATA.

    ASSIGN:

    LT_RESULT_D->* TO <LT_RESULT>,

    L_REC_D->* TO <L_REC>.

    • In addition, we also should create field symbols for every***

    • field which will be used directly in the further code.***

    FIELD-SYMBOLS : <CALMONTH2> TYPE /BI0/OICALMONTH2 .

    LOOP AT XTH_DATA ASSIGNING <L_REC>.

    ASSIGN COMPONENT :

    'S_CHAS-0CALMONTH2' OF STRUCTURE <L_REC> TO <CALMONTH2>.

    IF <CALMONTH2> = '02' .

    INSERT <L_REC> INTO TABLE <LT_RESULT>.

    ENDIF.

    ENDLOOP.

    If it solves ur query kindly close the thread and award points.

    Cheers

    Shafiq

    Add comment
    10|10000 characters needed characters exceeded