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: 

BAPI/RFC - Function module code explanation-VERY URGENT!!!!!

Former Member
0 Kudos

Hi folks,

I need to generate the report 'Order Status' on Java application from BW. I have the following fields in BW 0DOC_NUMBER, 0MATERIAL, 0REQ_DATE, ORDER_QUAN,0SHIP-TO and the report on Java portal has the fields like Order No, Product, Delivery Date, Ordered Quantity, Ship to location. So how do I proceed with the BAPI/RFC.

The steps to be followed are first create and function group and then name a function module and under attribute tab chose 'remote selection or so' and then in import parameters and export parameters, what do I need to chose and how to create a BAPI or function module. Can u just create one for the above example quoted? Any help would be great.

Thanks,

Nikki

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Import paramters:

OrderNumber

Export paramters:

Create a structure of the fields that you required.

ZORDER-VBELN

ZORDER-MATNR

ZORDER-EDATU

ZORDER-KWMENG

ZORDER-KUNNR

Use this new structure for your exporting parameters:

In the source code, use select statements against the sales document tables to get your data, filling the ZORDER structure.

Regards,

Rich HEilman

27 REPLIES 27

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Import paramters:

OrderNumber

Export paramters:

Create a structure of the fields that you required.

ZORDER-VBELN

ZORDER-MATNR

ZORDER-EDATU

ZORDER-KWMENG

ZORDER-KUNNR

Use this new structure for your exporting parameters:

In the source code, use select statements against the sales document tables to get your data, filling the ZORDER structure.

Regards,

Rich HEilman

athavanraja
Active Contributor
0 Kudos

are these fields are from ODS or cube? check out my weblog where i have explained how you could execute BW query using RFC. you could simply create a query with the required fields and use the explained procedure in my weblog to execute the query and get the results.

/people/durairaj.athavanraja/blog/2005/04/03/execute-bw-query-using-abap-part-i

/people/durairaj.athavanraja/blog/2005/04/03/execute-bw-query-using-abap-part-ii

if you dont like this approach, you can try MDX . check out the following weblog for the same.

/people/prakash.singh4/blog/2005/03/12/get-bw-data-in-portal-via-jca-using-mdx-statement

(this is a java iview code)

just for clarification. why dont you simply use bw query iview?

Regards

Raja

0 Kudos

Hello Raja,

Thanks for the reply. I created a query and tried to copy the same as in your weblog but couldn't understand how to define the structure ZBW_QUERY_OUTPUT_METADATA. After creating this RFC whatelse has to be done from SAP side and is there no necessity to create BAPIs and how should the Java programmer approach from here to apply this on the websphere portal.

Please this might look quite simple to you but its a bit complicated to me as I have very little knowledge in ABAP.

Nikki

0 Kudos

Raja,

Regarding the iview code, from BW side, I need to create the MDX statement and then define all the BAPI's listed and where does that code apply? I mean JAVA programmer is supposed to create where? on his application?

Let me know,

Thanks,

Nikki

0 Kudos

the sturcture ZBW_QUERY_OUTPUT_METADATA can be created from transaction SE11.

once you create the FM speicifed (with RFC enabled in the attributes tab of the FM). you dont need to do anything other than just creating queries. the java programmer either in his bean or in pageprocessor class will call this function module pass the required parameters and get the results.

<b>MDX</b>

in this case you dont need to do anything . this way you either directly query a cube using MDX or execute a query using MDX. constructing the MDX query statement can be done as a BW person by you from transaction MDXTEST.

and just pass it on to the java person. he will have to call BAPI_MDDATASET* FMs to pass this mdx and get the results.

Hope this is clear.

Regards

Raja

0 Kudos

Hi Raja,

Thanks again. I did the same as mentioned by you, created a query and copied the exact code as in the web log but just changed the query name and I need to do the same for 2 or 3 other queries. Am I going in the right direction? Do I need to add or change any fields from my query into the code you have written or is all that taken care of in the code itself.

Please let me know.

Nikki

0 Kudos

that one FM can run any query, thats the whole purpose of it. just pass the query name and its parameter to the FM. thats all you need to do.

Regards

Raja

0 Kudos

Hi again,

Sorry but can you tell me what this parameter is about? Do I have to give my own query variables if I have any for my query and if so what is this low and high becoz I do not see this options. I just see short and long text in the 'tables' tab.

Hoping to see an answer which would help me figure out if I am going in the right track.

Thanks,

Nikki

0 Kudos

example.

you have a query from cube "XYZ" called "MYQUERY"

and when you run it from BEX you pass a variable period (001.2005)(0P_FPER) to this query .

to execute this using FM

pass "XYZ/MYQUERY" to the parameter query_name.

pass "0P_FPER" to query_variables-vnam ,

"I" to query_variables-sign,

"EQ" to query_variables--opt,

"2005001" to query_variables-low .

Now you are ready to execute the FM to run the query "XYZ/MYQUERY" and get the results in XML format. (xml_out) and meta (tables parameter) would give you details about the result set , like column names, data type , etc.

Hope this is clear.

Regards

Raja

0 Kudos

Raja,

Firstly it doesn't accept '/' between the cube and query name, secondly I have a variable 0calday which is optional and in the 'tables' tab for defining the variables I have options like

Parameter name/Type spec/Associated type/Optional/Short text/Long text.

So I am defining it as

0CALDAY/LIKE/RRX_VAR/OPTIONAL/

Let me know please.

Thanks,

Nikki

Hi Raja,

Any updates for me please, can you please explain the table parameters again.???

0 Kudos

sorry for the delay, i wasn't at work. can you tell me which function module are you using. It looks to me that you are not using the FM from my weblog.

Regards

Raja

0 Kudos

Hi Raja,

I am using the same code (literally copy, pasted your code) you explained in the weblog but just changed the query name but here it accepts just the query name but not as you mentioned cube/query and I have a question regarding the table parameters as I have '0calday' and 'ship-to-location' as my variable option. This query I am building on a Multicube Y_SCM_MP1. Hope I am not wrong, let me know.

Thanks for your patience.

Nikki

Only change is I have given the function module name as Z_SD_ORDERSTATUS

Can you please explain what this is??

"CHAR50" must be a flat structure. You cannot use internal tables, strings, references, or structures as components.

0 Kudos

<i>Can you please explain what this is??

"CHAR50" must be a flat structure. You cannot use internal tables, strings, references, or structures as components.</i>

in the import parameter tab for parameter <b>QUERY_NAME</b> you would have specified the <b>type spec</b> as LIKE instead of type . please change it to type.

<i>just changed the query name but here it accepts just the query name but not as you mentioned cube/query</i>

i dont understand, when you call this FM (Z_SD_ORDERSTATUS) you need to pass "cube/queryname" to the <b>QUERY_NAME</b> parameter .

this example will work for multicube also, we have tested it.

<u>Let me explain what you have to do</u>

1. create the FM as explained in Execute BW query using ABAP Part I. you dont have to change anything, just copy paste it.

2. copy BAPI_IOBJ_GETDETAIL to Z_BAPI_IOBJ_GETDETAIL and comment the following code in the copied BAPI.

*  CALL METHOD cl_rsd_iobj=>authority_check
*    EXPORTING
*      i_iobjnm            = infoobject
*      i_activity          = rssb_c_auth_actvt-display
*    EXCEPTIONS
*      user_not_authorized = 1.
*  IF sy-subrc <> 0.
*    bapi_syserror.
*    EXIT.
*  ENDIF.

3. Now create the XSLT program as explained in Execute BW query using ABAP Part II (just copy paste it).

4. Now create a program from SE38 (type1) and copy paste the code given at the end of the blog. change the following code in this program to point to the XSLT program you have created in the previous step.

 TRY .
        CALL TRANSFORMATION (`<<b>this is your xslt program name</b>`)
        SOURCE XML  xml_out
        RESULT     outtab = <outtab>.
      CATCH cx_xslt_exception INTO xslt_error.
        xslt_message = xslt_error->get_text( ).
    ENDTRY.

5. fill the variables, in the following section of the code in the report program.

move: <cube/query name> to rpt_tech_id .
MOVE: '0CALDAY'  TO wa_var-vnam ,
  'I' TO wa_var-sign,
  'EQ' TO wa_var-opt, 
  <variable value> TO wa_var-low .
APPEND wa_var TO var .

Hope this is clear now.

Regards

Raja

0 Kudos

Hello Raja,

I gave the type spec as TYPE but when I define the cube name with the query name it gives the following error-"only use '/' as a namespace delimiter", example the one I named is Y_SCM_MP1/ZSD_MP02_ORDSTS.

Secondly when I go to transaction SE38 what are the steps involved in writing a source code. I defined my program name as ZCWS but what do I need to enter into the next page with type, status, application, authorization group. Once I enter this I can copy and insert the code you mentioned with the changed given.

Please let me know asap and at your convenience

Thanks,

Nikki

0 Kudos

<i>I gave the type spec as TYPE but when I define the cube name with the query name it gives the following error-"only use '/' as a namespace delimiter", example the one I named is Y_SCM_MP1/ZSD_MP02_ORDSTS.</i>

Do you meanto say that you typed in "Y_SCM_MP1/ZSD_MP02_ORDSTS" when you were creating a query in the BW query designer? there you will just give ZSD_MP02_ORDSTS . only when passing this value to the FM you will give it in cbe/query format.

<b><u>SE38</u></b>

type - executable program (1)

and give a description in the description field and hit save. thats all you need.

now in the next screen paste the code and modify the same as explained in the previous post.

Regards

Raja

0 Kudos

Hello Raja,

I named cube/query i.e. Y_SCM_MP1/ZSD_MP02_ORDSTS not in the query designer but while defining it in the import tab in the function module as follows:

Y_SCM_MP1/ZSD_MP02_ORDSTS TYPE CHAR50 PASS VALUE

I have an other question, do I need to create 3 other function modules under the same function group as I have 3 to 4 reports built on a third party tool.

Note: these 4 queries I am building on BW is from the same multicube. So am I supposed to define 4 queries in the same import tab or create 4 different function modules under same function group or different again??

Let me know.

Thanks,

Sree

0 Kudos

it has to be query_name and during runtime you will pass the cube/queryname to this parameter. thats where you are making a mistake. and you just have to create one FM, everytime you call this FM pass a different query name to this function. thats the whole purpose of this FM.

Regards

Raja

0 Kudos

Hello Raja,

I created the same way as you described in your weblog except that I changed the name of the function module. Now I have 4 to 5 queries on the same multicube which are generated in Websphere portal. So the Java programmers can call the same function module but giving 5 different query names as their import parameters and since the table parameter (0CALDAY) is already taken care of on the BW code, they can build 5 different java codes and run the portal.

Am I right??

Nikki

0 Kudos

you are right. use the same function module.

for query 1.

call the fm and pass query1 name and variables

for query 2

call the same fm and pass query2 name and variables

and so on.

<i><b>since the table parameter (0CALDAY) is already taken care of on the BW code</b></i>

is it same for allthe queries, table parameter has to be filled each time with that particular query's variables.

Regards

Raja

0 Kudos

Hello Raja,

I have a page 'order status' which has to show 'order details' in the same page when 'document number' is clicked ( this is all on Java side ). Now how do I implement this on BW front. Am I supposed to create an RRI between order status and order details as 2 different queries and try to drill down from one to the other. But does the Java programmer call 2 queries in one function module or how is this handled?? If not I need to inform them that both the header and details part need to show up in the same page so that I can avoid RRI's.

Please let me know your thoughts (RAJA where r u?????).

Nikki

Will these be my parameters?? Please confirm these.

Function module: ZSD_EXECUTE_QUERY

Table parameter: YSD_MP01/ZSD_MP_INVOICEDETAILS

Import parameter: 0DELIV_NUBB, 0BILL_NUM, 0DOC_NUMBER, 0CALDAY.

0 Kudos

i am right now holidaying in India. will be back to work on 11th august.

using the custom FM approach you cannot do RRI.

<i>Will these be my parameters?? Please confirm these.

Function module: ZSD_EXECUTE_QUERY

Table parameter: YSD_MP01/ZSD_MP_INVOICEDETAILS

Import parameter: 0DELIV_NUBB, 0BILL_NUM, 0DOC_NUMBER, 0CALDAY.</i>

query_name = YSD_MP01/ZSD_MP_INVOICEDETAILS

and fill the query variable table with

param name    sign   option   low
0DELIV_NUBB     I       EQ     <value>

Regards

Raja

0 Kudos

Wow, you r lucky :). I wish you a wonderful trip but at the same time please take few minutes of your time to look at this site and especially mine as I might not be in the same project by the time you come back ;).

I questioned about the parameters as I need to tell the Java programmer what he needs to input in his code. Was a bit confused with import parameter and table parameter. I am assuming that he needs to call the BAPI as ZSD_EXECUTE_QUERY, import parameter as YSD_MP01_ZSD_MP_INVOICEDETAILS (keeps changing for each query) and table parameters would be ODELIVE_NUBB, OBILL_NUM, 0DOC_NUMBER, 0CALDAY.

According to the weblog I don't have to insert any custom objects in the code other than building the same function modulu same to same and in the Java program insert the required parameters.

Am i correct?????

Please let me know as this is crucial.

Nikki

0 Kudos

Yes you are right.

Regards

Raja

0 Kudos

Hello Raja,

In the weblog you said that the export parameter would be xml_out which means the output is in the xml format. Is there an other way other than using xml output. Please let me know as the Java programmer can simplify the code accordingly. Do they have to use xml parser etc. Please let me know if there is an other way to call the output.

I know you are on your way back to US but just squeeze your time for this.

Nikki

0 Kudos

Hello,

I have corrected the function module Z_BAPI_IOBJ_GETDETAIL like in your post.

But I have a compilation error:

The field "RSA_C_RSAR" is unknown, but there are the following fields

with similar names:"RS_C_RSADMIN" and "RSAOT_C_SORT".

(row 116).

Have you an idea to correct this ? or could you copy/paste the function module ..

Thanks and regards,

Thibaut

0 Kudos

hi Thibaut

i am also facing this same problem. (compilation error)

if you have solved this problem then please tell me.

thanks

Kiran Patel

0 Kudos

I have also a compilation error:

The field "RSA_C_RSAR" is unknown, but there are the following fields

with similar names:"RS_C_RSADMIN" and "RSAOT_C_SORT".

Have you an idea to correct this ? Did anyone succeed ?

Please let me know !

Thank you in advance .