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: 

Probelm with FM GET_COMPONENT_LIST

Former Member
0 Kudos

I try to use GET_COMPONENT_LIST sending sy-repid for the prog name. When I use this function in a report program, it works fine. When I try to use it in a function group, it does not work properly. Any suggestions?

Code same attached.

Your help is greatly appreciated.

Kind Regards, Jason

FORM specify_columns  CHANGING p_lt_requ_columns TYPE crmt_report_requ_columns_ta .
  DATA: ls_requ_columns TYPE crmt_report_requ_columns,

        lt_components   TYPE TABLE OF rstrucinfo with header line,
        lv_components   LIKE LINE OF lt_components,

        lt_result          TYPE crmt_report_locatorlist_ta,
        ls_result          TYPE crmt_report_locatorlist.



  DATA: r_comp TYPE RANGE OF sychar30 WITH HEADER LINE.

*Build Param List of Fields We Want to Send Data
  r_comp-sign = 'I'.
  r_comp-option = 'EQ'.
  r_comp-low  = 'PERSON_RESP'.
  APPEND r_comp.

  r_comp-sign = 'I'.
  r_comp-option = 'EQ'.
  r_comp-low  = 'PERSON_RESP_LIST'.
  APPEND r_comp.
*
  CALL FUNCTION 'GET_COMPONENT_LIST'
    EXPORTING
      program    = sy-repid
      fieldname  = 'LS_RESULT'
    TABLES
      components = lt_components.

  IF sy-subrc = 0.
    LOOP AT lt_components INTO lv_components WHERE compname NOT IN r_comp.
      ls_requ_columns-column    = lv_components-compname.
      ls_requ_columns-requested = ''.
      APPEND ls_requ_columns TO p_lt_requ_columns.
    ENDLOOP.
  ENDIF.

8 REPLIES 8

naimesh_patel
Active Contributor
0 Kudos

Hello,

Pass the original program name instead of the sy-repid in the export parameter.

In FM, if you use the sy-repid, than system automatically takes the program name of the Function Group.

Regards,

Naimesh

Former Member
0 Kudos

Use SY-CPROG instead of SY-REPID. It should be work.

reward if helpful.

0 Kudos

These suggestions do not work. I tried using the include program name, the function group program name (ie. SAPL...), the function group name, the function name, and sy-cprog. Any other ideas?

0 Kudos

I would have thought that the function group main program name would have worked.

Regards,

RIch Heilman

0 Kudos

Hey Jason,

Hw r u? Well Jason...Have you declared all parameters correctly. I had used this FM in a function grp n it worked for me.

Here is the same code. Try giving the function group name in REPORT variable. Hope it helps.

<b>DATA: REPORT LIKE TRDIR-NAME</b>.

CALL FUNCTION 'GET_COMPONENT_LIST'
       EXPORTING
            PROGRAM    = REPORT
            FIELDNAME  = FIELD1
       TABLES
            COMPONENTS = COMPONENTS
       EXCEPTIONS
            OTHERS     = 1.

Hope it helps.

Rgds,

Naren

Message was edited by:

Somen

Former Member
0 Kudos

do not pass sy-cporg directly to FM

data v_prog type sy-cprog.

clear v_prog

v_prog = sy-cprog.

CALL FUNCTION 'GET_COMPONENT_LIST'

EXPORTING

program = v_prog

fieldname = 'LS_RESULT'

TABLES

components = lt_components.

see the results

0 Kudos

Still not working. This code works properly in a report program using sy-repid. I am now trying to use it in a function module which calls a subroutine that resides in the same function group (different include of course). I have tried all these suggestions, as well as, the obvious stuff like making sure the var name is correct, etc. Any other functions like COMPONENT_LIST that I can try???

0 Kudos

Okay guys, I got it. I had to use sy-repid, and declare the variable I am passing to fieldname as global.

Thanks for your efforts. I appreciate the help.

Kind Regards,

Jason