Open t-perry opened 2 years ago
Hi @perryt1 - I haven't touched this code in a long time, and I have not worked in the SAP space for quite a few years now. If I remember correctly, a 'P' type is internally a BCD? All the unpacking should pass through this function/switch - https://github.com/piersharding/RSAP/blob/master/src/RSAP.c#L594 . By default it will be treated as a string if the type is being mishandled. My starting point would be to check what fieldDesc.type
is for LGRAD
and then inspect the contents of value
. I'm sorry that I can't give any direct help as I no longer have access to R3 or RFC libs.
Thanks @piersharding - appreciate the info so far.
I can confirm that a P type is a BCD. How would I be able to look at the contents of value
?
You could try something like:
diff --git a/src/RSAP.c b/src/RSAP.c
index aa64152..dd22172 100644
--- a/src/RSAP.c
+++ b/src/RSAP.c
@@ -473,6 +473,8 @@ SEXP get_bcd_value(DATA_CONTAINER_HANDLE hcont, SAP_UC *name){
CHAR(u16to8(errorInfo.message)));
}
+ fprintf(stderr, "%s \n", buffer);
+
PROTECT(rfc_float = ScalarReal((double) atof(CHAR(u16to8((SAP_UC *)buffer)))));
free(buffer);
UNPROTECT(1);
@@ -594,6 +596,8 @@ void get_field_value(DATA_CONTAINER_HANDLE hcont, RFC_FIELD_DESC fieldDesc, SEXP
switch (fieldDesc.type) {
case RFCTYPE_FLOAT:
case RFCTYPE_BCD:
+ get_bcd_value(hcont, fieldDesc.name)
+ fprintf(stderr, "RFCTYPE_BCD: ");
SET_VECTOR_ELT(value, fld, allocVector(REALSXP, 1));
break;
I am trying to use RSAPReadTable to extract material information from SAP (Table MARC) and one of the fields required is LGRAD, which is a P of length 3.
The problem I am getting is the value is always returning as 0.
I have checked in SAP transaction and MM03 for the first row in the above image and the Service Level (LGRAD) field is set to 99.0
So I dug into the data with RSAPInvoke, I can see that the field is actually being returned with a *.0 or 0.0 value which the number handling in RSAPReadTable is correcting to 0.
I have a feeling that this is because the length is 3 but the value actually has a character length of 4.. but I wouldn't have a clue how to potentially address this or even if it is in RSAP or in RFC_READ_TABLE.