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

Syntax for Remote select stmt?

Former Member
0 Likes
1,011

Hi ,

How to write a remote select statement.?

I have to write remote slect stmt and get the details from MKPF table based on Material document number and year ,which should return TCODE2 data.

Thanks & Regards,

Gopi.

5 REPLIES 5
Read only

Former Member
0 Likes
777

Hi Gopi,

You need to create a RFC ( Remote Function Call ) which would fetch the data and return the parameter.

Goto SE80. Create a function group.

Goto SE37. Create a Function Module and in the Attributes TAB, tick Remote Function.

In the Import Tab, mention MBLNR

MJAHR

In the Export tab, mention TCODE.

Write a select query.

SELECT TCODE

from MKPF

into TCODE

where MBLNR = MBLNR

MJAHR = MJAHR.

Activate it.

Best regards,

Prashant

Pls. mark points for helpful answers

Read only

Former Member
0 Likes
777

Can be more clear on your requirement "Remote Select Stmt"

Maybe your option would be:

1. Create an RFC with 
   Import Parameters: Mat. Doc, Mat Doc Year.
   Export Parameter: Transaction Code/ Return

2. Source Code:

   select single tcode2 into out_tcode2
          from mkpf 
          where mblnr = in_mblnr
          and   mjahr = in_mjahr.
   if sy-subrc ne 0.
      move: 'Unable to retreive details for material document' to return.     
   endif.

Kind Regards

Eswar

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
777

"Remote" select statement? Do you mean getting the data from a remote system? If so you can use the function module RFC_READ_TABLE.

REgards,

RIch Heilman

Read only

0 Likes
777

For example, this code works pretty good.



report zrich_0001.

data: iopt type table of rfc_db_opt with header line.
data: ifld type table of rfc_db_fld with header line.
data: idat type table of tab512 with header line.

parameters: p_mblnr type mkpf-mblnr,
            p_mjahr type mkpf-mjahr.

* Where clause
concatenate 'MBLNR = ' p_mblnr '.' into iopt-text separated by space.
append iopt .
concatenate 'and MJAHR = ' p_mjahr '.'
        into iopt-text separated by space.
append iopt .

* Return Fields
ifld-fieldname = 'TCODE2'. append ifld.

call function 'RFC_READ_TABLE'
 destination 'PRD'      "  <---- Your RFC Destination
  exporting
    query_table                = 'MKPF'
    delimiter                  = ','
*   NO_DATA                    = ' '
*   ROWSKIPS                   = 0
*   ROWCOUNT                   = 0
  tables
    options                    = iopt
    fields                     = ifld
    data                       = idat
 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.

* Write return data.
loop at idat.
  write:/ idat.
endloop.

No need to create a custom RFC.

Regards,

Rich Heilman

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
777

Gopi, did this solve your problem? Please make sure to award points for helpful answers and mark as solved when solved completely. Thanks.

Regards

Rich Heilman