cancel
Showing results for 
Search instead for 
Did you mean: 

(unicode) dynamic assign

Clemenss
Active Contributor
0 Kudos

Hi,

I created a program for remote (RFC) comparison of table contents, especially to check for diefferenced in Customizing. A consutant puts all customizing tables to be compared over systems and clients into the selection variant. This enables quick check for any differences. And it can be repeated anytime.

FUNCTION 'RFC_GET_TABLE_ENTRIES' DESTINATION p_rfc

gets the table entries into a 1000 char wide unstructured table. To get the components entries, I tried to transfer the unstructured char data to structured component:

  • ps_struc is DDIC structure of table entries

  • <fts> and <ft> are untyped field symbols

  • create a data object of the actual DDIC type:

CREATE DATA lr_ref TYPE (ps_struc).

  • assign the structured component to field-symbol

ASSIGN lr_ref->* TO <fts>.

  • Loop at 1000 char table ASSIGNING untype field.symbol

LOOP AT pt_tab ASSIGNING <ft>.

  • move unstructured to structured

<fts> = <ft>.

DO.

ASSIGN COMPONENT sy-index OF STRUCTURE <fts> TO <fs>.

IF sy-subrc = 0.

  • Now the component's contents are assigned to <fs>

...

This works fine as long as the data are strictly CHAR type. In a unicode-compatible environment (starting with 4.7) dumps are created when there is any numeric component in the structure.

Now I'm looking for a solution. Three options are visible:

1. - check the structure type and ignore tables with non-char components

2. - get (and compare) only char components

3. - get and compare all kind of components

I could find a solution for option 1

For 2 or even 3 I'd be glad to find a way.

Thanks in Advance!

Regards,

Clemens

Accepted Solutions (0)

Answers (2)

Answers (2)

rainer_hbenthal
Active Contributor

Assume p0001 is structured and cprel is unstructred.

Old:

p0001 = cprel.

New unicode compliant:

FIELD-SYMBOLS: <p0001> type p0001.

ASSIGN cprel to <p0001> casting.

Now you have access to each component

<p0001>-pernr

Clemenss
Active Contributor
0 Kudos

this works because pernr is not numeric (P, i, f) but characterlike.

Thanks, but does not provide the solution.

ragards,

Clemens Li

rainer_hbenthal
Active Contributor
0 Kudos

This works for character und non-character components. try it with p0277, it has a decimal field in ps0277. I converted hundreds of programms to unicode with that method and it works.

Message was edited by: Rainer Hübenthal

athavanraja
Active Contributor
0 Kudos

not a direct answer to your question but check out this code sample , a modified RFC_READ_TABLE for eliminating the problem of unstructered data using XML

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn?rid=/library/uuid/f50dcd4e-0501-0010-3596-b686a7b51492">rfc_read_table for SAP Web AS</a>

Regards

Raja

Clemenss
Active Contributor
0 Kudos

Rainer,

we have a real unicode system here. The assign with casting addition ends with a dump. I'll be back on Monday, I remember it was a UC_.. exception citing invalid uncicode conversion.

The reason is (my guess) that double-byte character fields are transferred together with single-byte numeric fields which the casting addition is unable to handle.

Monday I'll try again, especially options 1 or 2 of my question.

Regards,

Clemens

Clemenss
Active Contributor
0 Kudos

Rainer,

now I got it: The dynamic assign as you proposed works fine, but not if the structure contains a field of type f as i.e. T006-TEMP_VALUE.

Any idea for that?

Regards,

Clemens

former_member186741
Active Contributor
0 Kudos

Clemens,

your problem is an alignment one, if float variables are included it will dump. To prevent this declare your table something like this:

types : BEGIN OF ty_BIG,

ALIGN1 TYPE F,

STUFF(5000),

END OF BIG.

data pt_tab type table of ty_big.

This will force alignment of the table.

Clemenss
Active Contributor
0 Kudos

Neil,

I don't understand completely.

I get the table contents in a char-like structure using FUNCTION 'RFC_GET_TABLE_ENTRIES' and I don't know how many if any f components are present. Which table should be declared as ty_BIG. Please explain.

TIA,

Clemens

former_member186741
Active Contributor
0 Kudos

Hi Clemens,

my solution didn't exactly suit but with a change I think it'll be ok. Check this out and see if it makes sense:

REPORT Znrw_RFC_GET_TABLE_ENTRIES_TES.

PARAMETERS : P_TAB type tabname DEFAULT 'T006'.

data w_tab type table of char512 with header line.

data : QUERY_TABLE like p_tab.

data : BEGIN OF BIG,

ALIGN1 TYPE F,

stuff type char512,

END OF BIG.

QUERY_TABLE = P_TAB.

DATA tabDREF TYPE REF TO DATA.

FIELD-SYMBOLS <tab> TYPE table.

FIELD-SYMBOLS <BIG> TYPE ANY.

CREATE DATA tabdref TYPE table OF (QUERY_TABLE).

ASSIGN tabDREF->* TO <tab>.

CALL FUNCTION 'RFC_GET_TABLE_ENTRIES'

EXPORTING

table_name = QUERY_TABLE

tables

entries = w_tab

.

loop at w_tab.

big-stuff = w_tab.

assign big-stuff to <big> casting type (QUERY_TABLE).

append <big> to <tab>.

endloop.

if sy-subrc = 0.

endif.