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: 

function-pool

aidan_mulcahy
Active Participant
0 Kudos
135

Hi,

I am implementing a BADI. In the method I call a SAP standard function. In the first line of the function I can see data in a table (no code at this point populates the table). This, I presume, has been populated by the function-pool the FM belongs to. I would like to see that table before calling the FM. Is it possible to declare the function-pool before I call the function so that I can see the table entries outside of the FM? In the code below the required table is 'gt_date_wrkt'. As you can see it is not populated in the FM itself.

Any suggestions?

method.....

...

call function 'CRM_DATES_READ_SINGLE_OB'

exporting

IV_DATESET_GUID = iv_ref_guid

IS_LOGICAL_DATE_KEY = lS_LOGICAL_DATE_KEY

importing

ES_DATE_WRK = ls_date_wrk

exceptions

PARAMETER_ERROR = 1

ENTRY_DOES_NOT_EXIST = 2

AT_LEAST_ONE_RECORD_NOT_FOUND = 3

ENTRY_IS_DELETED = 4.

.....

function crm_dates_read_single_ob .

statics: ls_date_wrk like line of gt_date_wrkt.

data: lt_dateset_guids type crmt_object_guid_tab,

lv_errorcode type sysubrc.

  • // check parameter

if iv_dateset_guid is initial and is_logical_date_key is initial.

message e103(crm_order_misc) raising parameter_error.

endif.

  • // read entry from object buffer

read table gt_date_wrkt into ls_date_wrk

with key guid = iv_dateset_guid

appt_type = is_logical_date_key-appt_type

is_duration = is_logical_date_key-is_duration.

Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
73

If the table of MAin Function Pool is populated you can see it in the program ( BADI ) before calling the FM.

Try this -

<b>DATA WA_NAME(50) vlaue

'(<MAIN_PROG_FUNC_POOL>) gt_date_wrkt[]'.

FIELD-SYMBOLS <F1> TYPE ANY .

ASSIGN WA_NAME TO <F1>.

IF SY-SUBRC EQ 0.

IF NOT <F1> IS INITIAL .

-


ENDIF.

ENDIF.</b>

You will have to find the name of Main program of function and then replace it in above code .

Cheers.

( Dont forget to reward points if answers were helpful).

8 REPLIES 8

Former Member
0 Kudos
74

If the table of MAin Function Pool is populated you can see it in the program ( BADI ) before calling the FM.

Try this -

<b>DATA WA_NAME(50) vlaue

'(<MAIN_PROG_FUNC_POOL>) gt_date_wrkt[]'.

FIELD-SYMBOLS <F1> TYPE ANY .

ASSIGN WA_NAME TO <F1>.

IF SY-SUBRC EQ 0.

IF NOT <F1> IS INITIAL .

-


ENDIF.

ENDIF.</b>

You will have to find the name of Main program of function and then replace it in above code .

Cheers.

( Dont forget to reward points if answers were helpful).

0 Kudos
73

Sanjay,

I have never used Field Symbols. How do I access the data once I have assigned the F-pool? There is a field in the gt_date_wrkt table called 'APPT_TYPE'. What would I do to read that?

Thanks,

Aidan.

0 Kudos
73

You can see only data defined in Function - Pool in this way provided it is available at runtime .

Define a similar internal table in your program .

"APPT_TYPE" seems to be a type defined in that function pool as I cannot find it in the dictionary.

Now put this code in your program

<b>DATA ITAB LIKE APPT_TYPE OCCURS 0 WITh HEADER LINE.</b>

( Above line may change as I am not sure how APPT_TYPE looks like )

<b>

DATA WA_NAME(50) vlaue

'(<MAIN_PROG_FUNC_POOL>)gt_date_wrkt[]'.

FIELD-SYMBOLS <F1> TYPE ANY .

ASSIGN WA_NAME TO <F1>.

IF SY-SUBRC = 0.

ITAB[] = <F1>.

ENDIF.</b>

Now Itab will be similar to what you have in gt_date_wrkt . You can loop on it or do whatever you want. <MAIN_PROG_FUNC_POOL> will be main program of actual function group name which you have not mentioned so far in your post.

Cheers

0 Kudos
73

Sanjay,

thanks again.

I am getting a short dump and the issue seems to be that that line is trying to assign a character string to an internal table.

The data is available at runtime (within the function module). e.g. The data I need is in gt_date_wrkt (table of CRMT_DATE_WRKT). In the code:

*********

method IF_EX_CRM_PRICING_BADI~CRM_PRICING_MERGE.

....

DATA WA_NAME(50) value '(SAPLCRM_DATES_OB)gt_date_wrkt[]'.

FIELD-SYMBOLS <F1> TYPE any.

DATA ITAB type table of CRMT_DATE_WRK.

ASSIGN WA_NAME TO <F1>.

IF SY-SUBRC EQ 0.

IF NOT <F1> IS INITIAL .

itab[] = <F1>. Short Dump here

ENDIF.

ENDIF.

....

  • I need the data here but it is not available

call function 'CRM_DATES_READ_SINGLE_OB'

-> the table is populated automatiaclly within the FM

*********

Maybe I am not understanding the Field Symbol but it looks like it is just try to assign a string of text to the itab?

Thanks,

Aidan.

0 Kudos
73

Hi Aidan,

You are almost there . Seems to be the ITAB definition causing the problem.

Try these in sequence.

1) Put a break point on IF NOT <F1> IS INITIAL and check the contens of <F1> in debugging. If asigned correctly then you will see its a table with one or multiple lines.

2) Now what is requirement .

IF <F1> is not initial means the internal table has data . You just want to check if internal table has data or you want to process it . If you want to process , just try below code . If you just want to check if itab has data then IF <F1> is not initial is sufficient .

data wa type CRMT_DATE_WRK.

..

...

IF NOT <F1> IS INITIAL .

LOOP AT <F1> INTO WA.

ENDLOOP

ENDIF.

Also give the details of dump. But try in debugging , it will be more helpfull.

Cheers

0 Kudos
73

Sanjay,

> IF <F1> is not initial means the internal table

> ble has data . You just want to check if internal

> table has data or you want to process it . If you

> want to process , just try below code .

This seems to be the issue. <F1> is not initial but it is not a table, it is just a character string:

DATA WA_NAME(50) value '(SAPLCRM_DATES_OB)gt_date_wrkt[]'.

FIELD-SYMBOLS <F1> TYPE any.

ASSIGN WA_NAME TO <F1>.

The result in debugging is:

<F1> = '(SAPLCRM_DATES_OB)gt_date_wrkt[]'.

So, when I loop at <F1>, it just fails.

I presume what should be happening is that the F-pool is accessed and gt_date_wrkt would be available?

Are my definitions OK?

Thanks,

Aidan.

0 Kudos
73

Sorry about that .

The correct statement is

ASSIGN <b>(</b>WA_NAME<b>)</b> TO <F1>.

( Now I think you previous code

itab[] = <F1> . should work )

Most of the problems you solve in debugging.

In debugging just put (SAPLCRM_DATES_OB)gt_date_wrkt[]

in the field name and you can see the data .

Cheers

0 Kudos
73

Sanjay,

that did it. Thanks a lot for your help. Just in time too.

Aidan.