cancel
Showing results for 
Search instead for 
Did you mean: 

RFC-XI-JDBC Scenario: Help with RFC code

Former Member
0 Kudos

HI,

I am doing RFC-XI-JDBC Scenario, where I have to poll the contents of my Ztable in SAP to Oracle.

The appraoach i am using here is :

1. Created a FM with import parameters as the fields of my Ztable and without any export parameter or source code.

2. Created a report to call that FM in background. The code of my report is as follows :

************************REPORT***********************************************************

Data: it_zrfc_read_table type table of zrfc_read_table,

wa_zrfc_read_table like line of it_zrfc_read_table.

PARAMETERS: tab_name like DD02L-TABNAME.

Data: l_tabname type DD02L-TABNAME.

At selection-screen.

select single tabname from DD02L into l_tabname where tabname = tab_name.

if sy-subrc <> 0.

message 'incorrect table name' type 'E'.

endif.

start-of-selection.

select * from (tab_name) into corresponding fields of table it_zrfc_read_table.

loop at it_zrfc_read_table into wa_zrfc_read_table.

CALL FUNCTION 'ZRFC_READ_TABLE2XI'

IN BACKGROUND TASK DESTINATION 'ORACLEGIS_RFC_SENDER'

EXPORTING

valve_id = wa_zrfc_read_table-valve_id

equnr = wa_zrfc_read_table-equnr

ernam = wa_zrfc_read_table-ernam

invnr = wa_zrfc_read_table-invnr

groes = wa_zrfc_read_table-groes

elief = wa_zrfc_read_table-elief

gwlen = wa_zrfc_read_table-gwlen

gwldt = wa_zrfc_read_table-gwldt

serge = wa_zrfc_read_table-serge

typbz = wa_zrfc_read_table-typbz.

endloop.

commit work.

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

NOw my problem is that although I am able to send a table with a single record, but when my records > 1, it is not able to poll.

Please guide me what can be altered in the code or any other suggestion.

Thanks,

Puneet

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Please suggest me if the Commit work statement is to be written before endloop or after endloop?

Prompt reply will be highly aprreciated.

Thanks,

Puneet

Former Member
0 Kudos

Instead of writing your function module in loop, first u execute it. take the data whatever is required in internal table. then create a dummy function module, pass this internal table to dummy FM. Dont write any code in dummy function module.

Now call this dummy function module in your code with BACKGROUND TASK and RFC destination. Also configure your scenario in XI using this dummy function module.

In case of any query, get back to me.

-Gouri

Award points if helpful.:)

Former Member
0 Kudos

Thanks Gouri, it was indeed a very helpful suggestion.

NOw, I would like to update few things here : the code i have pasted here is of my report which is calling the dummy FM.

NOw my problem is that if i create an internal table and pass the same to dummy FM then that dummy FM would not have fields which i need to map with my Target data type.

But if you do have a work around, please let me know .

Former Member
0 Kudos

Add the required fields in the internal table which you are going to pass to dummy function module. So that when you will upload this function module in IR you will get all the required fields for mapping.

-Gouri

Former Member
0 Kudos

Gouri,

Having said that Add the required fields in the internal table, did u mean to include the required fields in the internal table and the passing this internal table to the dummy FM with the required importing parameters.

The importing paramters of my dummy FM are :

VALVE_ID

EQUNR

ERNAM

INVNR

GROES

ELIEF

GWLEN

GWLDT

SERGE

TYPBZ

Can u also suggest me how can i pass an internal table into this dummy FM.

-- Puneet

Former Member
0 Kudos

give some inputs on how you are extracting data or what logic you have used.

I think whatever data u want to pass to target take it in internal table. make sure the fields of this table are the required fields which u r using in your mapping. So it will be easy for u.

-Gouri

Former Member
0 Kudos

Create a ztable in SE11 which will be having all the fields that are used in mapping. Now in report create your itab which will be of type this ztable.

Now first run your actual FM and fill this itab with target data. Now create your Dummy FM. this will be Remote enabled. in this go to table tab. add your itab over there and give the type ZTABLE. Dont write any code in this. Just activate it.

Now call this Dummy function module in your code with RFC. and use same dummy FM in IR too.

Hope u r clear.

In case of any doubt plz get back.

Warm Regards,

Gouri

Former Member
0 Kudos

Q:give some inputs on how you are extracting data or what logic you have used.

A: Please refer my code in the first post...I am using select on my Ztable.

Former Member
0 Kudos

Dummy Function module will not be having any import parameter. It will be having only one table parameter that is your internal table. Your actual function module will be having these importing parameters.

-Gouri

Former Member
0 Kudos

Dear Puneet,

I was asking abt code written in FM 'ZRFC_READ_TABLE2XI'. The code which u have posted I have already seen.

-Gouri

Former Member
0 Kudos

Gouri,

I am doing exactly the same as you said..except using a report instead of a FM for calling the dummy RFM.

NOw, my question is If i import the Remotely enabled FM (with only table tab = itab) in my IR then would i be able to see all my fields there or just the table name in request tab of this RFM.

Puneet

Former Member
0 Kudos

when u will import your RFC in IR u will see the complete structure including all fields of your itab. And you will have to call this dummy FM through report only and dont forget to use commit work after dummy FM call.

-Gouri

former_member301120
Active Participant
0 Kudos

Youre right,

if you import the FM in IR you´ll see the complete structure.

create a mapping, which creates a sqlstatement for all entries of the table

have a look at <a href="https://answers.sap.com/people/alessandro.berta/blog/2005/10/04/save-time-with-generalized-jdbc-datatypes:///people/alessandro.berta/blog/2005/10/04/save-time-with-generalized-jdbc-datatypes

I did it so and it works fine.

Christian

Former Member
0 Kudos

steps are as follows:

1. Call actually FM in report.

2. get the data in itab.

3. pass itab to dummy FM (In same report u shd call this dummy FM with RFC destination)

4. write commit work.

5. Execute the report.

After this do the necessary dev in IR and ID, and run your scenario.

It should work.

-Gouri

Former Member
0 Kudos

Thanks....it is working fine.....I had some doubt on importing the internal table but its clear now.

Thanks a ton....Gouri...for your prompt and valuable replies !!

PS: Awarded the well deserved Points.

Former Member
0 Kudos

Thanks Puneet.

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks fellow SDN members, I solved this problem from your inputs.

Former Member
0 Kudos

Hi Gouri,

I have one more query here.

I have done all the settings as suggested by you.

But now the occurences of the fields of my RFC (Sender) is 0...1 where it should be 1...unbounded.

Even my key field in the the table 0..1.

Please tell me how/where can i modify these occurences of source structure (RFC)?

Former Member
0 Kudos

Dear Puneet,

In your dummy RFC, in the Tables tab you must have specified your Itab and corresponding table. There you will find one optional checkbox. If you have not checked then it is mandatory. And if you click that checkbox then it bcome 0 to unbounded.

I think this is what u r looking for.

-Gouri

Former Member
0 Kudos

Hi Gouri,

As even i was doing same scenario wanted to know that as u said in order to make the fields appear 1..1 (mandatory ) table parameter in RFM shud be unchecked..thats right but will it make fields of that table mandatory in IR also?

if not then in case i hav one key field in that table how cna i make it mandatory in IR (se11 has got it as mandatory one),

also one doubt that, as per above discussion we hav to use 2 FM (FM, 1 RFM) in the report,

can u pls help in understanding wat actually is the use of FM created in rep as my selection screen passes the table name and select query populates the internal table that is used in RFM,

thanks

Former Member
0 Kudos

Hi Gouri,

As u said in order to make the fields appear 1..1 (mandatory ) table parameter in RFM shud be unchecked..thats right but will it make fields of that table mandatory in IR also?

if not then in case i hav one key field in that table how cna i make it mandatory in IR (se11 has got it as mandatory one),

Regards,

Puneet

turmoll
Active Contributor
0 Kudos

Hi,

Instead of calling RFC many times I would:

1) create RFM with only one import parameter

TYPE your_table type

2) call only once RFM in the report:


  CALL FUNCTION 'ZRFCNAME'
    IN BACKGROUND TASK
    DESTINATION 'RFCDEST'
    EXPORTING
      pt_table = i_table.

  COMMIT WORK AND WAIT.

This will also improve the performance.

Regards,

Jakub

Former Member
0 Kudos

Hi Jakub,

NOw if i go by this approach, then how would i map this table(source) with that of target message type( which happens to be Oracle in this case).