02-28-2007 3:10 AM
Friends,
I need help in assigning an integer value to type - lvc_t_nkey variable.
-
REPORT ZTEST111.
data: x type lvc_t_nkey,
y(12). " y can be either integer or numeric
x = y.
-
Error I get: the type X can't be converted to type y.
Thanks in advance
02-28-2007 5:14 AM
Hello Kartik
The type LVC_T_NKEY is a <b>table type</b>, thus your coding (x=y.) would mean:
Set <variable> = <table type>.
The line type of LVC_T_NKEY is LVC_S_NKEY. The same is true for almost all other LVC types, e.g.:
- fieldcatalog: LVC_<b>T</b>_FACT -> line type LVC_<b>S</b>_FCAT
LVC_T_ => table type
LVC_S_ => line type
You could write:
DATA:
gt_x TYPE lvc_t_nkey,
gs_y TYPE lcv_s_nkey. " or: LIKE LINE OF lvc_t_nkey
APPEND gs_y TO gt_x.
Regards
Uwe
02-28-2007 5:14 AM
Hello Kartik
The type LVC_T_NKEY is a <b>table type</b>, thus your coding (x=y.) would mean:
Set <variable> = <table type>.
The line type of LVC_T_NKEY is LVC_S_NKEY. The same is true for almost all other LVC types, e.g.:
- fieldcatalog: LVC_<b>T</b>_FACT -> line type LVC_<b>S</b>_FCAT
LVC_T_ => table type
LVC_S_ => line type
You could write:
DATA:
gt_x TYPE lvc_t_nkey,
gs_y TYPE lcv_s_nkey. " or: LIKE LINE OF lvc_t_nkey
APPEND gs_y TO gt_x.
Regards
Uwe
02-28-2007 7:58 PM
Uwe,
i have a need where after reading a internal table for a particular key e.g order number. the return from read is SY-TABIX.
I would like to use this value and expand the tree for the given node.
that is the reason i was trying to assign sy-tabix value in to lvc-t_nkey.
can I assign SY-TABIX to line type variable and append it to table type later ?
I appreciate your help.
Rgds,
Kartik
02-28-2007 8:24 PM
Hello Karthik
Use the following trick to map the tree nodes to the entries in you internal table:
TYPES: BEGIN OF ty_s_outtab.
INCLUDE TYPE sflight AS sflight.
TYPES: nkey TYPE lvc_s_nkey. " holds the key of the tree node
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
WITH DEFAULT KEY.
DATA:
gt_outtab TYPE ty_t_outtab.
The following coding has been taken from sample report <b>BCALV_TREE_DEMO</b> (routine <b>CREATE_HIERARCHY</b>) and slightly adjusted:
DATA:
ls_outtab TYPE ty_s_outtab.
LOOP AT gt_outtab INTO ls_outtab.
ld_idx = syst-tabix.
ON CHANGE OF ls_outtab-sflight-carrid.
PERFORM add_carrid_line USING ls_outtab-sflight
''
CHANGING l_carrid_key.
ls_outtab-nkey = l_carrid_key.
MODIFY gt_outtab FROM ls_outtab INDEX ld_idx
TRANSPORTING nkey. " store the node key with the itab entry
ENDON.
ON CHANGE OF ls_outtab-sflight-connid.
PERFORM add_connid_line USING ls_outtab-sflight
l_carrid_key
CHANGING l_connid_key.
" Also here: store the node key with the itab entry
ENDON.
PERFORM add_complete_line USING ls_outtab-sflight
l_connid_key
CHANGING l_last_key.
" Also here: store the node key with the itab entry
ENDLOOP.
Please note that there is no need to add field NKEY (of gt_outtab) to the fieldcatalog.
Regards
Uwe
03-01-2007 3:25 AM
02-28-2007 5:40 AM
Hi Kartik,
Havent tried this , but check if explicit type casting is supported.
Regards,
Sunmit.