on 06-19-2009 9:01 AM
Hi All,
I am new to SAP. and i am trying to get all enviornment details like Application server and runing applications, database configured on it printers of SAP using sapnwrfc SDK.
I am able to run the basic script and able to connect to SAP machine.
Could you please guide me how i can acheive getting whole enviornment details using PERL
Thanks in Advance,
Amit
Hiya Amit,
I'm not sure what exactly you need, but here's how to get the items listed in your question
-Function Module TH_WPINFO will give you the list of running processes in the same format as transaction SM50
-Surely you would have the application server name already if you are calling RFC functions?
- FM DB_DBNAME will give you the database (also check out DB_DBHOST, DB_DBSCHEMA, DB_GET_RELEASE)
-The list of printers is available in table SH_PRIN, do an RFC_READ_TABLE on this.
Also, 1995 called and they said they want their scripting language back
cough use Python cough
Cheers,
Gregor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks so much for your guidance Gregor,
My goal is here it find out following components of SAP setup:
SAP Server Attributes:
Version number
Central instance or not
SAP Services such as message queue, dialog
SAP Module ( Application deployed on SAP Application server
Printer
Database used by SAP application server.
I need a Perl script or guidance to get these environment details of SAP environment.
Thanks Again for your help:)
Amit
Hi,
I am getting following error when i fire the function TH_WPINFO:
RFC Error: Problem Invoking RFC (RPY_PROGRAM_READ): 5 / NOT_FOUND / ID:XI Type:E
Number:004 TH_WPINFO
Can you guide me on how to resolve this error?
My code is:
use sapnwrfc;
use Data::Dumper;
SAPNW::Rfc->load_config;
my $conn = SAPNW::Rfc->rfc_connect;
print "Testing SAPNW::Rfc-$SAPNW::Rfc::VERSION\n";
my $attrib = $conn->connection_attributes;
warn Dumper($attrib);
my $rd = $conn->function_lookup("RFC_READ_TABLE");
my $rc = $rd->create_function_call;
$rc->QUERY_TABLE("SH_PRIN");
#$rc->DELIMITER("|");
#$rc->OPTIONS([{'TEXT' => 'MANDT <> \'000\''}]);
$rc->invoke;
warn Dumper($rc->DATA);
$rd = $conn->function_lookup("RPY_PROGRAM_READ");
$rc = $rd->create_function_call;
$rc->PROGRAM_NAME("TH_WPINFO");
eval {
$rc->invoke;
};
if ($@) {
die "RFC Error: $@\n";
}
print "Program name: ".$rc->PROG_INF->{'PROGNAME'}."\n";
my $cnt_lines_with_text = scalar grep(/LGRFCUXX/, map { $_->{LINE} } @{$rc->SOURCE_EXTENDED});
$conn->disconnect;
Thanks,
Amit
Hi Gregor,
FM DB_DBNAME not exposed through remote call. I am getting following error when i try to access it through RFC:
"Problem Invoking RFC (DB_DBNAME): 3 / CALL_FUNCTION_NOT_REMOTE / The function mo
dule "DB_DBNAME" not released for 'remote' calls."
Can you help me on this?
Thanks in Advance,
Amit
Hi Amit,
Ok, if you want to run this FM then do the following:
- Copy the FM to a Z version so I have ZDB_DBNAME
- Change the processing type to Remote-enabled on the attributes tab
- Change the type of DBNAME in the exporting tab to char200
- Save and activate the function module
The following Python then works for me:
import pysap
import time
import sys
conn='LCHECK=1 ASHOST=127.0.0.1 CLIENT=500 SYSNR=00 USER=guten PASSWD=morgan'
sap_conn=pysap.Rfc_connection(conn)
try:
sap_conn.open()
except pysap.SapRfcError,desc:
print desc
sys.exit(1)
func=sap_conn.get_interface('ZDB_DBNAME')
try:
rc=func('DBNAME')
except pysap.SapRfcError,desc:
print "Error : %s" % desc
stuff = func['DBNAME']
print stuff
RPY_PROGRAM_READ is a function module to read the code of a program. You haven't provided it with a program name, you've provided it with a function module name (TH_WPINFO). That's why you got the error "NOT FOUND", because the function module is not listed in table TRDIR, which is where programs are listed.
Function modules are accessible via t-code SE37, whereas programs are accessible via SE38. Any program you can find via SE38 should be able to be read with RPY_PROGRAM_READ.
Cheers,
David.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.