12-03-2007 11:21 AM
Hii All,
how to access deep strucvture data
in my case
SHP_SERNR_UPDATE_T is a table type and
SHP_SERNR_UPDATE_S is the struture in thi table
..
how to declare in my program to access this structure and table..
plzz give one example of of this..
12-03-2007 11:23 AM
hI
structures containing internal tables as components or
Internal table containing Structure as components are called Deep Internal table.
A nested structure is a structure that contains one or more other structures as components. Flat structures contain only elementary data types with a fixed length (no internal tables, reference types, or strings). The term deep structure can apply regardless of whether the structure is nested or not. Nested structures are flat so long as none of the above types is contained in any nesting level.
Any structure that contains at least one internal table, reference type, or string as a component (regardless of nesting) is a deep structure. Accordingly, internal tables, references, and strings are also known as deep data types. The technical difference between deep structures and all others is as follows. When you create a deep structure, the system creates a pointer in memory that points to the real field contents or other administrative information. When you create a flat data type, the actual field contents are stored with the type in memory. Since the field contents are not stored with the field descriptions in the case of deep structures, assignments, offset and length specifications and other operations are handled differently from flat structures.
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb2fcc358411d1829f0000e829fbfe/content.htm
Please check this link for reading a deep structure.
Example:
TYPES: BEGIN OF TYPE_DEEP,
MATNR TYPE MATNR,
T_MARC TYPE MARC OCCURS 0,
END OF TYPE_DEEP.
DATA: T_DEEP TYPE STANDARD TABLE OF TYPE_DEEP.
DATA: WA_DEEP TYPE TYPE_DEEP.
DATA: T_MARC TYPE TABLE OF MARC.
DATA: S_MARC TYPE MARC.
Populating data.
WA_DEEP-MATNR = 'TEST'.
S_MARC-MATNR = 'TEST'.
S_MARC-WERKS = '9090'.
APPEND S_MARC TO T_MARC.
Append second level internal table.
WA_DEEP-T_MARC[] = T_MARC[].
Append.
APPEND WA_DEEP TO T_DEEP.
Process the internal table.
LOOP AT T_DEEP INTO WA_DEEP.
WRITE: / WA_DEEP-MATNR.
PROCESS the second level internal table.
LOOP AT WA_DEEP-T_MARC INTO S_MARC.
WRITE: S_MARC-WERKS.
ENDLOOP.
ENDLOOP.
12-03-2007 11:24 AM
Hi!
DATA: gt_sernr LIKE SHP_SERNR_UPDATE_T,
wa_sernr LIKE LINE OF gt_sernr.
LOOP AT gt_sernr INTO wa_sernr.
MOVE 'A' TO wa_sernr-SHP_SERNR_UPDATE_S-field.
MODIFY gt_sernr FROM wa_sernr INDEX sy-tabix.
ENDLOOP.
Regards
Tamá
12-03-2007 11:48 AM
Hii.. still not clear with deep structure.. please
in my case
table SHP_SERNR_UPDATE_T
contains SHP_SERNR_UPDATE_S structure inside..
this structure has
vbeln, posnd and sernr fields ..
how to access these from this structure..
please
12-03-2007 12:06 PM
Hi
I can't understand the relation beetween SHP_SERNR_UPDATE_T
and SHP_SERNR_UPDATE_S.
If SHP_SERNR_UPDATE_T is type table based on SHP_SERNR_UPDATE_S:
DATA: ITAB TYPE SHP_SERNR_UPDATE_T,
WA TYPE SHP_SERNR_UPDATE_S.
LOOP AT ITAB INTO WA.
WRITE: WA-VBELN,
WA-POSND,
.................................
ENDLOOP.
Max
12-03-2007 12:42 PM
Hi Max
in this Fm
SD_DELIVERY_UPDATE_PICKING_1
it contains table type for serial number SHP_SERNR_UPDATE_T
and structure line type SHP_SERNR_UPDATE_S
SHP_SERNR_UPDATE_S-RFBEL
SHP_SERNR_UPDATE_S-RFPOS
SHP_SERNR_UPDATE_S-SERNR
to acces sthiese filds i need code in my program
12-03-2007 1:13 PM
Hi
It means the table type SHP_SERNR_UPDATE_T is based on line type SHP_SERNR_UPDATE_S, so just as we said in previous answers you need to loop the table using a work area defined as SHP_SERNR_UPDATE_S.
DATA: WA TYPE SHP_SERNR_UPDATE_S.
LOOP AT ITAB INTO WA.
WRITE: WA-RFBEL,
WA-RFPOS,
WA-SERNR.
ENDLOOP.
Max
12-03-2007 1:18 PM
Hi!
DATA: gt_sernr LIKE SHP_SERNR_UPDATE_T, "itab using the table type
wa_sernr LIKE LINE OF gt_sernr. "line of the itab
LOOP AT gt_sernr INTO wa_sernr.
WRITE:/ wa_sernr-SHP_SERNR_UPDATE_S-RFBEL,
wa_sernr-SHP_SERNR_UPDATE_S-RFPOS,
wa_sernr-SHP_SERNR_UPDATE_S-SERNR. "put a - sign before the field name
ENDLOOP.
Regards
Tamá
12-03-2007 11:31 AM
Hi
DATA: <TABLE> TYPE SHP_SERNR_UPDATE_T,
<WORK AREA> TYPE SHP_SERNR_UPDATE_S.
So you can read the table by LOOP or READ TABLE statament
LOOP AT <TABLE> INTO <WOR AREA>.
ENDLOOP.
READ TABLE <TABLE> INTO <WORK AREA>.
If there's a table in the structure, you need to declare a new work area like that table:
DATA: <WORK AREA 2> TYPE ............
LOOP AT <TABLE> INTO <WOR AREA>.
LOOP AT <WORK AREA>-ITAB INTO <WORK AREA 2>.
ENDLOOP.
ENDLOOP.
Max