Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Adding field in field catalog and to display in output

Hi, In this below report i have newly added the user group field i.e' usr02-class ' and the field and data is coming up to internal table ' it_usr02 ' in 'REUSE_ALV_GRID_DISPLAY' and in field catalog it is not coming i have debugged and only the class field is not coming. plz suggest me how to add this in fieldcatalog .

REPORT zrpbc_user_log.

----


  • Declaration of Tables *

----


TABLES: usr02,usr03.

DATA:

BEGIN OF it_usr02 OCCURS 0,

bname LIKE usr02-bname, "EID

class LIKE usr02-class, "User Group

trdat LIKE usr02-trdat, "Last Logged in Date

*Start of Change Charm 25971

name1 LIKE usr03-name1, "First Name

name2 LIKE usr03-name2, "Last Name

e_mail LIKE bapiaddr3-e_mail,"Emailid

*End of Change Charm 25971

END OF it_usr02.

DATA: w_address TYPE bapiaddr3,

it_return TYPE STANDARD TABLE OF bapiret2,

w_name LIKE bapibname-bapibname.

TYPE-POOLS: slis.

DATA it_fcat TYPE slis_t_fieldcat_alv.

DATA : w_fcat TYPE slis_fieldcat_alv.

----


  • Declaration of Constants *

----


CONSTANTS: c_past_days TYPE i VALUE 90.

----


  • Declaration of Variables *

----


DATA w_repid LIKE sy-repid.

DATA w_no_lines LIKE sy-tabix.

DATA w_idx TYPE sy-tabix.

----


  • Selection Screen *

----


SELECT-OPTIONS:

s_trdat FOR usr02-trdat.

----


  • INITIALIZATION *

----


INITIALIZATION.

PERFORM initialize_data.

----


  • Start of Selection *

----


START-OF-SELECTION.

*Get the user details

PERFORM get_user_details.

----


  • End of Selection *

----


END-OF-SELECTION.

PERFORM get_alv_display.

&----


*& Form initialize_data

&----


  • text

----


FORM initialize_data .

"Initialize the select options with the appropriate date range

s_trdat-low = sy-datum - c_past_days.

s_trdat-high = sy-datum.

s_trdat-sign = 'I'.

s_trdat-option = 'BT'.

APPEND s_trdat.

ENDFORM. " initialize_data

&----


*& Form get_user_details

&----


  • text

----


FORM get_user_details .

  • read data into table it_usr02

SELECT bname class trdat

FROM usr02

INTO TABLE it_usr02

WHERE

trdat IN s_trdat AND

bname LIKE 'E%'.

LOOP AT it_usr02.

w_idx = sy-tabix.

MOVE : it_usr02-bname TO w_name.

*Start of Change Charm 25971

    • Getting the First ,Last name & Emailid of the user

CALL FUNCTION 'BAPI_USER_GET_DETAIL'

EXPORTING

username = w_name

IMPORTING

address = w_address

TABLES

return = it_return.

MOVE : w_address-firstname TO it_usr02-name1,

w_address-lastname TO it_usr02-name2,

w_address-e_mail TO it_usr02-e_mail.

MODIFY it_usr02 INDEX w_idx.

ENDLOOP.

*End of Change Charm 25971

ENDFORM. " get_user_details

&----


*& Form get_alv_display

&----


  • text

----


FORM get_alv_display.

w_repid = sy-repid.

PERFORM get_alv_fieldcat.

  • Create Field-catalogue from internal table

  • Call for ALV list display

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = w_repid

it_fieldcat = it_fcat

i_save = 'A'

TABLES

t_outtab = it_usr02

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

WRITE: /

'Returncode'(001),

sy-subrc,

'from FUNCTION REUSE_ALV_LIST_DISPLAY'(002).

ENDIF.

ENDFORM. " get_alv_display

&----


*& Form get_alv_fieldcat

&----


  • text

----


FORM get_alv_fieldcat .

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = w_repid

i_internal_tabname = 'IT_USR02'

i_inclname = w_repid

CHANGING

ct_fieldcat = it_fcat

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

WRITE: /

'Returncode'(001),

sy-subrc,

'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'(002).

ENDIF.

*Start of Change Charm 25971

w_fcat-reptext_ddic = 'Firstname'(003).

MODIFY it_fcat FROM w_fcat TRANSPORTING reptext_ddic

WHERE fieldname = 'NAME1'.

w_fcat-reptext_ddic = 'Lastname'(004).

MODIFY it_fcat FROM w_fcat TRANSPORTING reptext_ddic

WHERE fieldname = 'NAME2'.

*End of Change Charm 25971

ENDFORM. " get_alv_fieldcat

Former Member
Not what you were looking for? View more on this topic or Ask a question