on 01-12-2011 8:04 AM
Hi,
with sapnwrfc packet from Piers Harding (v0.31) I try to create a salesorder within a perl script.
Without using table ORDER_CONDITIONS_IN my salesorder is created successfull in SAP.
Now I want to commit pricing information. Therefor I used ORDER_CONDITIONS_IN with syntax:
$rc->ORDER_CONDITIONS_IN([{'COND_P_UNT'=>'1', 'CURRENCY'=>'EUR', 'COND_TYPE'=>'PR00', 'ITM_NUMBER'=>'000010', 'COND_VALUE'=>'22'}]);
SAP returned an error: BCD_BADDATA
So I thought something wrong with COND_P_UNT or COND_VALUE because these have to be BCD packed values.
Now I tried something like
pack("H*", "22")
for COND_VALUE and so on. But without success.
Some values I commited in table ORDER_ITEMS_IN are marked as BCD but I have to send them in "plain" text, no pack function to call...
So, did you have any idea for solving my problem?
Is it possible that another (incomplete) table is responsible for my problem?
Or do you think the reason is dedicated to table ORDER_CONDITIONS_IN?
Any help or suggestion appreciated!
Regards,
Patrick
So you're looking to populate the ORDER_CONDITIONS_IN structure. Here's an example of how I've populated two structures OPTIONS and FIELDS:
my $it = $rfc->function_lookup("RFC_READ_TABLE");
my $rcb = $it->create_function_call;
$rcb->QUERY_TABLE("SNAP");
$rcb->DELIMITER(";");
$rcb->OPTIONS([{'TEXT' => "SEQNO = '000' AND "},{'TEXT' => "(DATUM > '$mindate' OR (DATUM = '$mindate' AND UZEIT > '$mintime'))"}]);
$rcb->FIELDS([{'FIELDNAME' => 'DATUM'},{'FIELDNAME' => 'UZEIT'},{'FIELDNAME' => 'AHOST'},{'FIELDNAME' => 'UNAME'},{'FIELDNAME' => 'MANDT'},{'FIELDNAME' => 'FLIST'}]);
$rcb->invoke;
Hope that helps,
david.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
thanks for your code.
Unfortunately I have tested this style of structure already without success.
Did anyone use ORDER_CONDITIONS_IN to populate pricing information?
Maybe another programming language than perl can be helpful!
Or did anyone know about the term BCD_BADDDATA or how I can get Information about which field is affected?
I also tried client side debugging/tracing but there are no relevant information within the logs.
Patrick
Yes, I've gotten BCD_BADDDATA before, when the input was not structured correctly. Are you sure you tried changing
$rc->ORDER_CONDITIONS_IN([{'COND_P_UNT'=>'1', 'CURRENCY'=>'EUR', 'COND_TYPE'=>'PR00', 'ITM_NUMBER'=>'000010', 'COND_VALUE'=>'22'}]);
to
$rc->ORDER_CONDITIONS_IN([{'COND_P_UNT'=>'1'},{'CURRENCY'=>'EUR'},{'COND_TYPE'=>'PR00'},{'ITM_NUMBER'=>'000010'},{'COND_VALUE'=>'22'}]);
If you can post all of your code here, I will test it as well.
Additionally, you can inspect the rfc trace by setting
trace: 1
in your sap.yml (or similar) file. You can set trace higher than 1 if you wish also. This will create a trace file in the same directory as your script.
Hi David,
yes, I tried it in your given syntax.
Here my actual code but with seperatly build arrays.
I had to restructure beacause of many loops.... But finally thats what I did.
Lines marked with '#!' are specific and have to be adapted to your system.
Uncommenting the line where populating ORDER_CONDITIONS_IN produces the error.
use Data::Dumper;
use sapnwrfc;
my @orderHeaderIn;
my @orderPartners;
my @orderItemsIn;
my @orderSchedulesIn;
my @orderCfgsInst;
my @orderConditionsIn;
$orderHeaderIn->{DOC_TYPE} = 'ZRAS'; #!
$orderHeaderIn->{SALES_ORG} = '055'; #!
$orderHeaderIn->{DISTR_CHAN} = '01'; #!
$orderHeaderIn->{DIVISION} = 'IE'; #!
$orderHeaderIn->{REQ_DATE_H} = '20101231';
$orderPartners->[0]{PARTN_NUMB} = '0000008759'; #!
$orderPartners->[0]{PARTN_ROLE} = 'AG'; #!
$orderItemsIn->[0]{ITM_NUMBER} = '000010';
$orderItemsIn->[0]{PLANT} = '0551'; #!
$orderItemsIn->[0]{MATERIAL} = '000000000000368388'; #!
$orderItemsIn->[0]{ORDERID} = '000552551003'; #!
$orderItemsIn->[0]{PURCH_DATE} = '20101030';
$orderItemsIn->[0]{TARGET_VAL} = '22';
$orderItemsIn->[0]{BILL_DATE} = '20101030';
$orderItemsIn->[0]{TARGET_QTY} = '22';
$orderSchedulesIn->[0]{ITM_NUMBER} = '000010';
$orderSchedulesIn->[0]{REQ_QTY} = '22';
$orderCfgsInst->[0]{QUANTITY_UNIT} = 'STZ'; #!
$orderConditionsIn->[0]{ITM_NUMBER} = '000010';
$orderConditionsIn->[0]{COND_VALUE} = '22';
$orderConditionsIn->[0]{CURRENCY} = 'EUR';
$orderConditionsIn->[0]{COND_P_UNT} = '1';
$orderConditionsIn->[0]{COND_TYPE} = 'PR00'; #!
SAPNW::Rfc->load_config('path_to_sap.yml'); #!
my $con = SAPNW::Rfc->rfc_connect;
my $rd = $con->function_lookup("BAPI_SALESORDER_CREATEFROMDAT2");
my $rc = $rd->create_function_call;
$rc->ORDER_HEADER_IN($orderHeaderIn);
$rc->ORDER_PARTNERS($orderPartners);
$rc->ORDER_ITEMS_IN($orderItemsIn);
$rc->ORDER_SCHEDULES_IN($orderSchedulesIn);
$rc->ORDER_CFGS_INST($orderCfgsInst);
#$rc->ORDER_CONDITIONS_IN($orderConditionsIn);
$rc->invoke;
print "salesdocument: ".$rc->SALESDOCUMENT."\n";
print "RetVal: ".Dumper(@{$rc->RETURN})."\n";
$rd = $con->function_lookup("BAPI_TRANSACTION_COMMIT");
$rc = $rd->create_function_call;
$rc->WAIT("x");
$rc->invoke;
$con->disconnect;
I already set trace to 1 in sap.yml. Now I will try with a higher value.
Thanks for that hint.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.