Access Tables Via RFC

Access Tables Via RFC

If you are trying to read some information from SAP and you can't find the right BAPI then RFC_READ_TABLE can do the job for you.

RFC_READ_TABLE is powerful RFC it gives you the access to all tables and views in SAP. I basically used RFC_READ_TABLE for Material Master Search application on the Intranet.

Now you may say there are lots of BAPI for this functionality. You are right but I had to work around the BAPI to get Prices (Moving Average Price) and it just did not work very well. Because of the nature of the application I had to use RFC_READ_TABLE because then I can use powerful SQL expression for searching. RFC_READ_TABLE give you the ability to code the where clause which is quite enough.

I have included part of the code use in asp page to read ENT1027 for Mgroup and M description & number but without object creation. The other part of the code reads MBEW for price & quantity.


lt;%
'#######################Diming the Structures
Call BAPIRFC.DimAs("Rfc_Read_Table", "FIELDS", MaterialSelection_RS)
Call BAPIRFC.DimAs("Rfc_Read_Table", "OPTIONS", Selection_RS)
'###################################################################
'########################Search Type########################
' C contanis
' S Start with
' E Ends with
if searchtype = "C" then
FormatedSearch_Keyword = "%" & Search_Keyword & "%" 
elseif searchtype = "S" then
FormatedSearch_Keyword = Search_Keyword & "%" 
else searchtype

    Requires Free Membership to View

    When you register, you will start receiving targeted emails from my award-winning team of editorial writers. Our goal is to keep you informed on the hottest topics and biggest challenges faced by SAP professionals today.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchSAP.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchSAP.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

= "E" then FormatedSearch_Keyword = "%" & Search_Keyword end if '################################## '################# Flaged for deletion Materials ##################### if showdeleted = "No" then Selection_RS.AddNew Array("TEXT"),Array("LVORM <> 'X' AND") end if '##################################################################### '############## users can search three material group ################ '############## GROUPS: OFFICESUP TECOMHARD TECOMSOFT ############### '##USER STILL CAN NAROW THEIR SEARCH BY SELECTING ON OF THREE######### if MGroup = "ALL" then Selection_RS.AddNew Array("TEXT"),Array("MATKL IN ('OFFICESUP','TECOMHARD','TECOMSOFT')") else Selection_RS.AddNew Array("TEXT"),Array("MATKL = '"& MGroup &"' and ") end if '###################################################################### '#######################ADDING SEARCH KEYWORD TO STRUCTURE############## if not Search_Keyword = "" then Selection_RS.AddNew Array("TEXT"),Array(" MAKTG LIKE '" & FormatedSearch_Keyword & "'") end if Selection_RS.Update '################################################################### '#######################ADD RETURNED FIELDS######################### MaterialSelection_RS.AddNew array("FIELDNAME","OFFSET","LENGTH","TYPE","FIELDTEXT"),array("MATNR","000000","000000" ,"","") MaterialSelection_RS.AddNew array("FIELDNAME","OFFSET","LENGTH","TYPE","FIELDTEXT"),array("MATKL","000000","000000" ,"","") MaterialSelection_RS.AddNew array("FIELDNAME","OFFSET","LENGTH","TYPE","FIELDTEXT"),array("MAKTG","000000","000000" ,"","") MaterialSelection_RS.Update call BAPIRFC.Rfc_Read_Table("ENT1027", Material_RS, MaterialSelection_RS, Selection_RS, "~", "", "0", "0") If Err.Number > 0 then Response.Write "Error:" & "<BR>" Response.Write " Err.number...... " & Err.Number & "<BR>" Response.Write " Err.Description. " & Err.Description & "<BR>" end if '###########LOOP THROUGH RECORDSET if not Material_RS is nothing then do while not Material_RS.eof loop end if
%>

This was first published in April 2002

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.