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: 

Internal table using 'LVC_FIELDCATALOG_MERGE'

Former Member
0 Kudos
3,427

Dear Everyone,

I tried to build field category reference to an internal table using 'LVC_FIELDCATALOG_MERGE', but it didn't work. I already export the internal table name to I_INTERNAL_TABNAME, but the result table gt_fieldcat was empty. However, I also export the internal table name to I_STRUCTURE_NAME, the run-time error will be occurred.

Can somebody advise that what the problem is? I listed the code below.

I know that 'REUSE_ALV_FIELDCATALOG_MERGE' can do that, but I received a message from SAP that they don't recommend we use it anymore, so I have to use 'LVC_FIELDCATALOG_MERGE'.

Thanks in advanced !

Best Regards,

Leo Lau

Code:

  • Prepare field category

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

*I_STRUCTURE_NAME = 'alv_output'

I_INTERNAL_TABNAME = 'alv_output'

CHANGING

ct_fieldcat = gt_fieldcat

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

  • Structure definition

DATA: BEGIN OF alv_output OCCURS 10,

mandt TYPE mandt ,

infnr TYPE infnr ,

...

DATA: END OF alv_output.

  • Variable definition

DATA : gt_fieldcat TYPE lvc_t_fcat,

.......

1 ACCEPTED SOLUTION

Former Member
0 Kudos
466

Hi All,

Thanks you for your reply.

Hi Vijay Babu Dudla,

Thank you for your reply.

When we follow your suggestion to implement my program and execute the program, some errors messages will be displayed.

Runtime Errors --> READ_REPORT_LINE_TOO_LONG

EXCEPT. --> CX_SY_READ_SRC_LINE_TOO_LONG

Error Occured in

Function Module : K_KKB_FIELDCAT_MERGE

Line 365 : read report l_prog_tab_local into L_abap_source

Thanks in advance.

Best Regards,

Leo

8 REPLIES 8

Former Member
0 Kudos
466

HI,

In your code...CHECK

1) I-INTERNAL_TABNEM = 'ALV_OUTPUT'

internal table name should be in capital letters.

2) in the structure definition dont use TYPE always use LIKE

Regards,

Kiran

former_member188685
Active Contributor
0 Kudos
466

It will not work directly, But there is a work around. check this...

REPORT  ZTEST_FIELDCATLOG.
type-pools: slis.

data: begin of it_data occurs 0,
        vbeln like vbak-vbeln,
        matnr like mara-matnr,
      end of it_data.

DATA: it_fieldcat type SLIS_T_FIELDCAT_ALV,
     it_lvcfcat type lvc_t_fcat.
 
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
 EXPORTING
   I_PROGRAM_NAME               = sy-repid
   I_INTERNAL_TABNAME           = 'IT_DATA'
   I_INCLNAME                   =  sy-repid
  CHANGING
    ct_fieldcat                  = it_fieldcat
* EXCEPTIONS
*   INCONSISTENT_INTERFACE       = 1
*   PROGRAM_ERROR                = 2
*   OTHERS                       = 3
          .
IF sy-subrc  0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
 
 
CALL FUNCTION 'LVC_TRANSFER_FROM_SLIS'
  EXPORTING
    it_fieldcat_alv       = it_fieldcat
*   IT_SORT_ALV           =
*   IT_FILTER_ALV         =
*   IS_LAYOUT_ALV         =
 IMPORTING
   ET_FIELDCAT_LVC       = it_lvcfcat
*   ET_SORT_LVC           =
*   ET_FILTER_LVC         =
*   ES_LAYOUT_LVC         =
  tables
    it_data               = it_data
* EXCEPTIONS
*   IT_DATA_MISSING       = 1
*   OTHERS                = 2
          .
IF sy-subrc  0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
 
BREAK-POINT.

Regards

Vijay Babu Dudla

0 Kudos
466

Good solution

bpawanchand
Active Contributor
0 Kudos
466

Hi

[Check out|;

Regards

pavan

Former Member
0 Kudos
467

Hi All,

Thanks you for your reply.

Hi Vijay Babu Dudla,

Thank you for your reply.

When we follow your suggestion to implement my program and execute the program, some errors messages will be displayed.

Runtime Errors --> READ_REPORT_LINE_TOO_LONG

EXCEPT. --> CX_SY_READ_SRC_LINE_TOO_LONG

Error Occured in

Function Module : K_KKB_FIELDCAT_MERGE

Line 365 : read report l_prog_tab_local into L_abap_source

Thanks in advance.

Best Regards,

Leo

0 Kudos
466
Runtime Errors --> READ_REPORT_LINE_TOO_LONG
EXCEPT. --> CX_SY_READ_SRC_LINE_TOO_LONG

Error Occured in
Function Module : K_KKB_FIELDCAT_MERGE
Line 365 : read report l_prog_tab_local into L_abap_source

Caution:-

Source code lines should be less than or equal to 72,. when you are using the REUSE Merge function.

0 Kudos
466

width of the source code lines should be less than or equal to 72.

width

read table it_data with key vbeln = vbeln matnr = matnr posrn = posnr.

if there are such lines convert or format them

read table itab with key vbel = vbef
                     nmt = mat

Former Member
0 Kudos
466

Hi Vijay Babu Dudla,

Thank you for your reply.

It is work.

Thanks a lot !

Regards,

Leo Lau