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: 

lvc_t_nkey - please help

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

uwe_schieferstein
Active Contributor
0 Kudos

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

5 REPLIES 5

uwe_schieferstein
Active Contributor
0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

Thank you...

Former Member
0 Kudos

Hi Kartik,

Havent tried this , but check if explicit type casting is supported.

Regards,

Sunmit.