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

How do I use module K_COSTELEM_SELECT,

Former Member
0 Likes
1,684

I am trying to use FM K_COSTELEM_SELECT and I see it doens't have any exports but it has a talbe. How can i get at the data in the talbe if it doens't export anything out of the FM.

I am trying to use FM K_COSTELEM_SELECT and I see it doens't have any exports but it has a talbe. How can i get at the data in the talbe if it doens't export anything out of the FM.

12 REPLIES 12
Read only

Former Member
0 Likes
1,587

may be u have to pass some data into the table and it will return the final data within the table.

Read only

0 Likes
1,587

Yes i pass data in but is that data going to be avaible to me in code if it doesn't export back out

Read only

venkata_ramisetti
Active Contributor
0 Likes
1,587

Hi,

It will return you the populated internal table back.

Check the code in the FM K_COSTELEM_BAPI_GETLIST.

This function module is calling this function module.

Thanks

Ramakrishna

Message was edited by:

Ramakrishna Ramisetti

Read only

0 Likes
1,587

Oh even if there isnt an export statement

Read only

Former Member
0 Likes
1,587

The output returned by the function module is an internal table of generic type. Its structure would be based on what it returns; which again would be dependent upon how it is called.

For example you can have a program that returns back vendor or customer master records (LFA1 or KNA1) based on how it is called. The program can have just one output parameter, i.e. internal table of type generic, which would contain internal table of LFA1 if it was called to get vendor master record; or would contain internal table of type KNA1 if it is called to get customer master record.

This is same scenario with the function module that you are trying to call. You can store its results in an internal table, say MY_TEMP_TBL, which should be defined in your program as:

DATA: MY_TEMP_TBL OCCURS 0.

Use this as parameter to receive IT_RESULT parameter of your function module.

Regards,

Chetan Singh

You can store its results in variable L_RESULT, which should be defined as

Read only

0 Likes
1,587

Ignore last line in my previous reply. Forgot to delete it.

Read only

0 Likes
1,587

so shoud I use the bapi or the FM

Read only

0 Likes
1,587

Use the same function module that you are using.

Get the export parameter in the temporary field defined in your program (as described in my previous note).

Read only

0 Likes
1,587

Use same function module K_COSTELEM_SELECT. No need to change your code.

Read only

0 Likes
1,587

thanks. SO do I just you a read or append statment to load into the table?

Read only

0 Likes
1,587

1. First, execute/debug your program to see whether the table is really getting populated after the function call.

2. Then you can read the table in your program by simple internal-table READ statement or loop through it to get the records. You may have to first assign the received parameter to a FIELD-SYMBOL variable before you read it. Field-symbol documentation is available at:

http://help.sap.com/saphelp_erp2005vp/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/frameset.htm

Hope it helped to resolve your problem.

Regards,

Chetan

Read only

0 Likes
1,587

I did what you said and when I debug it has data whne it is in the function module but when it comes back to the program the table,lt_cskb_ex, is empty. here is the code, pretty easy but it is empty

----


----


  • Work areas *

----


DATA : WA_TPI3K TYPE TPIK3,

WA_TPIR2T TYPE TPIR2T.

DATA: MY_TEMP_TBL TYPE cskb_ex OCCURS 0 WITH HEADER LINE,

lt_cskb_ex TYPE cskb_ex OCCURS 0 WITH HEADER LINE.

----


  • START-OF-SELECTION

----


START-OF-SELECTION.

PERFORM GET_PM_COST_CAT.

read table lt_cskb_ex into MY_TEMP_TBL.

************************************************************************

END-OF-SELECTION.

************************************************************************

FORM GET_PM_COST_CAT.

CALL FUNCTION 'K_COSTELEM_SELECT'

EXPORTING

kokrs = '1000'

ce_group = 'PMSERVICES'

  • date_from = date

  • date_to = dateto

TABLES

it_result = lt_cskb_ex

EXCEPTIONS

no_record_found = 1

group_not_found = 2.