Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass the Dynamically table name and RELID in IMPORT x TO y FROM DATABASE dbtab(ar) ID Key

Former Member
0 Kudos

Hello Expert,

I wanted to know is there any way through which we can dynamically pass the table name in IMPORT condition.

For e.g.

DATA : PCLT TYPE DD03L-TABNAME.

DATA: SET_RELID TYPE T52RELID-RELID.

DATA: key TYPE PCLKEY.

DATA: text_version TYPE PVRSN.

DATA: BEGIN OF ptext OCCURS 132.

DATA: line(132).

DATA: END OF ptext.

SET_RELID = 'TX'.

PCLT = 'PCL1'.

KEY = '00001000004005     9999123119960101000'.

TEXT_VERSION = '01'.

IMPORT TEXT_VERSION PTEXT FROM DATABASE <PCLT>(<SET_RELID>) ID KEY.

If i use this then it gives me error message "The Dictionary structure or table "<PCLT>" is either not active or does not exist."

Kindly help me in this matter.

Thanks

Srikanth

1 ACCEPTED SOLUTION

former_member197622
Participant
0 Kudos

Hi Srikanth

I dont know if there is another solution, but this is what i did using a dynamic subroutine, please check it

just add this lines to your code

DATA: prog  TYPE c LENGTH 8,

       mess TYPE string,

       sid  TYPE string,

       wrd  TYPE string,

       dir  TYPE trdir,

       OFF(3).

DATA: lt_code TYPE TABLE OF rssource-line.

DATA: ls_code TYPE rssource-line.

perform call_import using pclt set_relid key.

form call_import USING p_pclt p_set_relid p_key.

   ls_code = 'PROGRAM SUBPOOL.'.

   append ls_code to lt_code.

   ls_code = 'form get_text tables ptext using p_key changing text_version.'.

   append ls_code to lt_code.

   ls_code = 'IMPORT text_version ptext from database'.

   append ls_code to lt_code.

   concatenate p_pclt '(' p_set_relid ')' into ls_code.

   append ls_code to lt_code.

   ls_code = 'id p_key.'.

   append ls_code to lt_code.

   ls_code = 'endform.'.

   append ls_code to lt_code.

             .

   generate subroutine pool lt_code

                       name prog

                       message mess

                       SHORTDUMP-ID sid

                       WORD WRD

                       OFFSET OFF.

   IF SY-SUBRC EQ 0.

     perform GET_TEXT IN PROGRAM (prog) tables ptext

                                          USING p_key

                                          CHANGING text_version .

   ENDIF.

endform.

Hope this help

Regards

MC

11 REPLIES 11

former_member197622
Participant
0 Kudos

Hi Srikanth

I dont know if there is another solution, but this is what i did using a dynamic subroutine, please check it

just add this lines to your code

DATA: prog  TYPE c LENGTH 8,

       mess TYPE string,

       sid  TYPE string,

       wrd  TYPE string,

       dir  TYPE trdir,

       OFF(3).

DATA: lt_code TYPE TABLE OF rssource-line.

DATA: ls_code TYPE rssource-line.

perform call_import using pclt set_relid key.

form call_import USING p_pclt p_set_relid p_key.

   ls_code = 'PROGRAM SUBPOOL.'.

   append ls_code to lt_code.

   ls_code = 'form get_text tables ptext using p_key changing text_version.'.

   append ls_code to lt_code.

   ls_code = 'IMPORT text_version ptext from database'.

   append ls_code to lt_code.

   concatenate p_pclt '(' p_set_relid ')' into ls_code.

   append ls_code to lt_code.

   ls_code = 'id p_key.'.

   append ls_code to lt_code.

   ls_code = 'endform.'.

   append ls_code to lt_code.

             .

   generate subroutine pool lt_code

                       name prog

                       message mess

                       SHORTDUMP-ID sid

                       WORD WRD

                       OFFSET OFF.

   IF SY-SUBRC EQ 0.

     perform GET_TEXT IN PROGRAM (prog) tables ptext

                                          USING p_key

                                          CHANGING text_version .

   ENDIF.

endform.

Hope this help

Regards

MC

0 Kudos

Hello Marco,

Thanks for your help.

It really works for me.

In this program one problem is there. It is that if First IMPORT condition provide the value and then again if i execute the function and in that new Import condition if there is no value, then too it provide the previous text value.

Do you know how to clear the Subpool memory. so the each call provide the new value.

Thanks again.

Regards

Srikanth

0 Kudos

Hi Srikanth,

sorry, i didnt understand you, can you explain a little more ? i think that you should clear the table before use it, is that returning the same value after a call where there should not be?

Regards

MC

0 Kudos

Hello Marco,


Yes it was returning the same value of previous call.


Now it is working fine, I have clear the table before using it.


Just let me know whether is need to clear the memory of Subpool?


Regards,

Srikanth

0 Kudos

i didnt try a more elaborate code, it should have all the parameters clear since its a sobroutine without any global parameter

If you are going to make a lot of calls then it will be good to check the parameters before using it

dynamic code its a little tricky sometimes

the code of subpool will be available until the end of the internal session

"A temporary subroutine pool generated for an internal mode cannot be explicitly deleted. It remains available from its generation up to the point where the internal session is terminated."

Regards

MC

0 Kudos

Thanks Marco,

I will make sure that all the parameters are clear.

Thanks for your prompt reply.

Regards,

Srikanth

0 Kudos

No problem, i never doubt to help when i can and thats the good thing about getting the notifications on the cel (: hahahaha

Regards

MC

0 Kudos

Hello Marco,

Finally i have done all the things.

But while testing i come to know that subroutine pools cannot be generated more then 36.

Do you know how to overcome this. As i wanted to call the program more then 36 times.

Please help me on this. Also let us know if you need more information in this regards

Thanks

Srikanth

0 Kudos

maybe you could reuse some subroutines, are those more than 36 subroutines different ?

can you give more details about what are you importing ?

Regards

MC

0 Kudos

Hello Marco,

Below is the code which i have placed in the function module.

If in this function module i make a call continuously and when the CALL count comes to 36 it gives dump error.

IF TABNAME IS NOT INITIAL and PCL_KEY is NOT INITIAL.

  ls_code = 'PROGRAM SUBPOOL.'.

  append ls_code to lt_code.

  IF TEXT_VERSION is not initial.

  ls_code = 'form get_text tables ptext using PCL_KEY changing TEXT_VERSION.'.

  append ls_code to lt_code.

  ls_code = 'IMPORT TEXT_VERSION ptext from database'.

  append ls_code to lt_code.

  Else.

  ls_code = 'form get_text tables ptext using PCL_KEY.'.

  append ls_code to lt_code.

  ls_code = 'IMPORT ptext from database'.

  append ls_code to lt_code.

  EndIF.

  concatenate TABNAME '(' SET_RELID ')' into ls_code.

  append ls_code to lt_code.

  ls_code = 'id PCL_KEY.'.

  append ls_code to lt_code.

  ls_code = 'endform.'.

  append ls_code to lt_code.

  generate subroutine pool lt_code

    name prog

    message mess

    SHORTDUMP-ID sid

    WORD WRD

    OFFSET OFF.

  IF SY-SUBRC EQ 0.

  IF TEXT_VERSION is not initial.

  perform GET_TEXT IN PROGRAM (prog) tables ptext

  USING PCL_KEY

  CHANGING TEXT_VERSION .

  ELSE.

  perform GET_TEXT IN PROGRAM (prog) tables ptext

  USING PCL_KEY.

  ENDIF.

  ENDIF.

ENDIF.

So how can i come to know that the first call is being made and second Call is being made.

From this i can write IF statement so it generate subroutine one time only.

Thanks,

Srikanth

0 Kudos

I found a hint in that problem in this thread

Maybe you could create a more elaborated code to reuse all the subroutines, i mean, are you calling more than 36 different imports ?