Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Table data mis-aligned from non-unicode server to unicode client C program

former_member183984
Participant
0 Kudos
116

We have an ABAP function module that is RFC-enabled. It allows to retrieve a table of spool requests for a given user in a given output device (from TSP01 table)

We have created a Windows C++ Unicode program that is linked to the version 7.11 of SAP UNICODE RFC SDK (version of librfc32u.dll is 7110.0.46.6208). This program first connects to the SAP System then calls the ABAP function.

The list of is returned in a RFC_TABLE like this:

tables[0].name = L"TA_SPOOLLIST";

tables[0].nlen = (int) wcslen(tables[0].name);

tables[0].type = TYPC;

tables[0].leng = 1000;

tables[0].itmode = RFC_ITMODE_BYREFERENCE;

tables[0].newitab = 0;

tables[0].ithandle = ItCreate(L"TA_SPOOLLIST", 1000, 0, 0);

Each line is then transferred into a C structure mapping the fields of TSP01.

We have no problem retrieving the fields when we connect to a Unicode SAP system (ECC6 here). However when you we try to retrieve a TSP01 structure from a NON-UNICODE system (4.7 here) the alignment of the fields in the structure is screwed:

- INT4 fields are coded on 8 bytes (4-bytes with a Unicode SAP system)

- INT2 fields are coded on 4 bytes (2-bytes with a Unicode SAP system)

Moreover, it seems that "padding" bytes are added in the structure, especially before INT2 fields.

Is it a known issue and is there a corrective, whether on SAP system or in RFC library?

If this is a normal behavior, is there an explanation about the strange structure alignment and how to handle it?

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos
71

it's absolutely normal in ABAP : see [abap documentation - Alignment of data objects|http://help.sap.com/abapdocu_70/en/ABENALIGNMENT.htm] and [abap documentation - Alignment in Unicode Systems|http://help.sap.com/abapdocu_70/en/ABENUNICODE_ALIGNMENT.htm]. Couldn't find more information about how to handle alignment with RFC. If you do, please tell us

3 REPLIES 3

Sandra_Rossi
Active Contributor
0 Kudos
72

it's absolutely normal in ABAP : see [abap documentation - Alignment of data objects|http://help.sap.com/abapdocu_70/en/ABENALIGNMENT.htm] and [abap documentation - Alignment in Unicode Systems|http://help.sap.com/abapdocu_70/en/ABENUNICODE_ALIGNMENT.htm]. Couldn't find more information about how to handle alignment with RFC. If you do, please tell us

0 Kudos
71

I saw in srfctest.h program supplied with RFC library, that alignment is hard coded for a test structure :


static RFC_UNICODE_TYPE_ELEMENT typeOfRfcTest[] =
{
{ cU("Rfcfloat"),        RFCTEST_RFCFLOAT_TYP,  16,   8,   0,   8,   0,   8,   0 },
{ cU("Rfcchar1"),        RFCTEST_RFCCHAR1_TYP,   0,   1,   8,   2,   8,   4,   8 },
{ cU("Rfcint2"),         RFCTEST_RFCINT2_TYP,    0,   2,  10,   2,  10,   2,  12 },
{ cU("Rfcint1"),         RFCTEST_RFCINT1_TYP,    0,   1,  12,   1,  12,   1,  14 },
{ cU("Rfcchar4"),        RFCTEST_RFCCHAR4_TYP,   0,   4,  13,   8,  14,  16,  16 },
{ cU("Rfcint4"),         RFCTEST_RFCINT4_TYP,    0,   4,  20,   4,  24,   4,  32 },
{ cU("Rfchex3"),         RFCTEST_RFCHEX3_TYP,    0,   3,  24,   3,  28,   3,  36 },
{ cU("Rfcchar2"),        RFCTEST_RFCCHAR2_TYP,   0,   2,  27,   4,  32,   8,  40 },
{ cU("Rfctime"),         RFCTEST_RFCTIME_TYP,    0,   6,  29,  12,  36,  24,  48 },
{ cU("Rfcdate"),         RFCTEST_RFCDATE_TYP,    0,   8,  35,  16,  48,  32,  72 },
{ cU("Rfcdata1"),        RFCTEST_RFCDATA1_TYP,   0,  50,  43, 100,  64, 200, 104 },
{ cU("Rfcdata2"),        RFCTEST_RFCDATA2_TYP,   0,  50,  93, 100, 164, 200, 304 }
};

which corresponds to what we find in SAP SE11 transaction for RFCTEST structure (you can see the alignment (OFFSET) by using menu Utilities | Runtime object | Display):

 
Field	 OFFSET
RFCFLOAT    0
RFCCHAR1    8
RFCINT2    10   realigned from 9 to 10 (gap of 1 octet)
RFCINT1    12
RFCCHAR4   13
RFCINT4    20   realigned from 17 to 20 (gap of 3 octets)
RFCHEX3    24
RFCCHAR2   27
RFCTIME    29
RFCDATE    35
RFCDATA1   43
RFCDATA2   93

With srfctest.h and srfctest.c, I guess you should have all the info you need. Good luck !

0 Kudos
71

Thank you Sandra, this really put me on the good track to solve my problem.