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

Function Module

Former Member
0 Likes
765

Which Function module I have to use extract data from one client to abap program in another client.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
737

Hi, if the clients are within the same instance, then this is quite easy. You can actually specify the client in your WHERE clause in your SELECT statements, so you could run a program in client 100 which is getting data from client 300.

Select * into table imara from mara
             where mandt = '300'
                and mtart = 'HALB'.

If the clients are not of the same instance, then of course you need to use RFC connections and the already mentioned funciton module to bounce to the other instance and retrieve the data.

Regards,

RIch HEilman

8 REPLIES 8
Read only

ferry_lianto
Active Contributor
0 Likes
737

Hi,

Do you mean to read/extract table data?

If you do then you can this FM RFC_READ_TABLE.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
737

Question is not clear :

You can use BAPI,ALE/IDOC's ,EDI

Or simple BDC You can Write

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
738

Hi, if the clients are within the same instance, then this is quite easy. You can actually specify the client in your WHERE clause in your SELECT statements, so you could run a program in client 100 which is getting data from client 300.

Select * into table imara from mara
             where mandt = '300'
                and mtart = 'HALB'.

If the clients are not of the same instance, then of course you need to use RFC connections and the already mentioned funciton module to bounce to the other instance and retrieve the data.

Regards,

RIch HEilman

Read only

0 Likes
737

The clients are not of the same instanc. The data needs to be pulled from two tables. Should I use the rfc twice to populate the data into 2 internal tables...and finally combine them into a single internal table...............

Read only

0 Likes
737

You will need to call it twice, how you do it is up to you, but if you want to be a little more dynamic and code the call only once, you can do something like this.



report zrich_0001.

data: it001 type table of t001.
data: xt001 like line of it001.
data: it005 type table of t005.
data: xt005 like line of it005.

start-of-selection.

* Pass the name of the internal table, the work area, and the name of the table
  perform read_table using 'IT001' 'XT001' 'T001'.
  perform read_table using 'IT005' 'XT005' 'T005'.

* write out the data that was retrieved.
  loop at it001 into xt001.
    write:/ xt001.
  endloop.

  loop at it005 into xt005.
    write:/ xt005.
  endloop.

*---------------------------------------------------------------------*
*       FORM read_table                                               *
*---------------------------------------------------------------------*
form read_table using itab_name wa_name table_name.

  data: opt type table of rfc_db_opt with header line.
  data: fld type table of rfc_db_fld with header line.
  data: tab type table of tab512 with header line.

  data: istr type table of string.
  data: xstr type string.

  field-symbols: <fs_tab> type table,
                 <fs_wa>,
                 <fs>.

  assign (itab_name) to <fs_tab>.
  assign (wa_name) to <fs_wa>.

  call function 'RFC_READ_TABLE'
    destination 'PRD'
    exporting
      query_table                = table_name
      delimiter                  = ','
    tables
      options                    = opt
      fields                     = fld
      data                       = tab
   exceptions
     table_not_available        = 1
     table_without_data         = 2
     option_not_valid           = 3
     field_not_valid            = 4
     not_authorized             = 5
     data_buffer_exceeded       = 6
     others                     = 7.

  loop at tab.
    split tab at ',' into table istr.
    loop at istr into xstr.
      assign component sy-tabix of structure <fs_wa> to <fs>.
      if sy-subrc = 0.
        <fs> = xstr.
      endif.
    endloop.
    append <fs_wa> to <fs_tab>.
  endloop.

endform.


Regards,

RIch Heilman

Read only

0 Likes
737

One more quick question

How do I search FM which suit my requirement

Lets say for POPUP of messages.... How do i find the function modules

Read only

ferry_lianto
Active Contributor
0 Likes
737

Hi,

Yes ... you need to execute FM RFC_READ_TABLE twice to read two different database tables and store both data to one internal table.

Regards,

Ferry Lianto

Read only

ferry_lianto
Active Contributor
0 Likes
737

Hi,

Please go to transaction SE37 and enter POPUP then press F4 (pull down). System will then show list of FM with POPUP wildcard.

Then you try to select and test the FM which meet your requirement.

Here are examples:

POPUP_FOR_INFORMATION

POPUP_WITH_2_BUTTONS_TO_CHOOSE

POPUP_WITH_3_BUTTONS_TO_CHOOSE

POPUP_TO_CONFIRM

POPUP_GET_VALUES

POPUP_TO_DECIDE_LIST

POPUP_WITH_TABLE

POPUP_TO_INFORM

Regards,

Ferry Lianto

Make sure you mark for helpful answers.