Application Development and Automation 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: 
Read only

Check in Function if optional table is existing

Former Member
0 Likes
1,773

Dear all

I have a function module where I have a table as optional parameter.

No I should be able to check if this table is existing or not. How can this be done?

I tried several things like try + catch but nothing worked. All lead in an exception when it is not given to the function.

Thank you

Herbert

Dear all

I have a function module where I have a table as optional parameter.

No I should be able to check if this table is existing or not. How can this be done?

I tried several things like try + catch but nothing worked. All lead in an exception when it is not given to the function.

Thank you

Herbert

12 REPLIES 12
Read only

Former Member
0 Likes
1,649

Just use as;

IF itab[] IS INITIAL. "No table passed
"Do operations without table
ELSE.
"Do operations with table
ENDIF.

This will solve your problem.

Regards

Karthik D

Read only

Former Member
0 Likes
1,649

Hi,

You can define your table like this in the TABLES tab:

TAB TYPE STANDARD TABLE

Regards,

Ali

Read only

JozsefSzikszai
Active Contributor
0 Likes
1,649

the way to do it:

IF itab IS SUPPLIED.
...
ENDIF.

Read only

Former Member
0 Likes
1,649

Thanx for your fast replies.... but the problem is a little bit more complex, sorry for not giving all details at begining.

So the problem is following that in User Exit RV63A901 we like to use the table TKOMP.

This user exit is called by 2 FM.

PRICING_COMPLETE

PRICING_SUBSCREEN_PAI

in PRICING_COMPLETE TKOMP is not optional, but in the other one it is marked as OPTIONAL and therefore it's not available.

Using the solution with 'IS SUPPLIED' does not work in this case because I'm not directly in the FM I guess.

The solution IS INITIAL finish in a dump GETWA_NOT_ASSIGNED.

Are there any other ideas?

Read only

0 Likes
1,649

Then check IS ASSIGNED.

Regards

Karthik D

Read only

0 Likes
1,649

This unfortunatly does not work. Because TKOMP is not a Field symbol. Also when the dump calls it like this

Read only

0 Likes
1,649

Hi,

Anyhow since its a table, use DESCRIBE TABLE and check SY-TFILL or lines.

DESCRIBE TABLE itab.
IF SY-TFILL EQ 0. "IF no records exist
"Do without table
ENDIF.

And this is my last suggestion, i will be glad if it works

Regards

Karthik D

Read only

0 Likes
1,649

Hi,

I am also facing same issue, any solution please update here.

Thanks & Regards

Vijayanand Poreddy

Read only

0 Likes
1,649

Hello Herbert,

I assume you get a dump information like this:

>

> This error may occur if

> - you address a typed field symbol before it has been set with

> ASSIGN or

> - if you address a global function interface partameter, even

> though the relevent function module is not active,

> i.e. it is not in the list of active calls. You can get the list

> of active calls from the this short dump.

>

Thus access to optional parameters is not possible in case the function module has not been called. Sounds like you need to know which module is calling your exit. If there is no obvious way to do so possibly it would make sense to check for notes in the customer service system.

Best Regards

Klaus

Read only

Former Member
0 Likes
1,649

Hi,

You could call function SYSTEM_CALLSTACK to determine from which function the user exit is being called. Depending on the outcome, you could then decide to use the table or not.

Rgds,

Mark

Read only

Former Member
0 Likes
1,649

For Eg:

Your Table name which is given in FM is T_data.

Now you declare your own internal table of the same type in the exit and write the code like this.

 it_internal_tab[] = t_data[].
*now check whether it_internal table is initial or not

Regards,

Mayank

Read only

0 Likes
1,649

Hi,

I got a solution for this issue, but i am not able to justify what is the logic behind this. i kept a check above my code as follows

IF preisfindungsart_kopf is not initial.

<my exisisting code>

ENDIF

with this check, the code will be executed only after TKOMP is filled/avialable in that routine.

Regards

Vijayanand Poreddy