‎2006 Oct 06 2:01 AM
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.
‎2006 Oct 06 2:05 AM
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
‎2006 Oct 06 2:05 AM
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
‎2006 Oct 06 2:06 AM
‎2006 Oct 06 2:21 AM
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
‎2006 Oct 06 1:51 PM