Skip to Content
0
Former Member
Sep 11, 2013 at 05:55 PM

Combine Invoice Number and Fiscal Year for CDHDR

446 Views

Hi,

I currently creating a report to view incominginvoice released via mrbr however i'm not sure how to handle the objectid as it will be an invoice number + fiscal year.

How would i combine the two fields for the below report?

*---------------------------------------------------------------------

*This ALV report displays tables CDHDR and CDPOS *

*---------------------------------------------------------------------

TYPE-POOLS slis. " Global ALV types

*---------------------------------------------------------------------

* constants

*---------------------------------------------------------------------

CONSTANTS : c_x VALUE 'X',

c_eb9 TYPE syucomm VALUE '&EB9',

c_refresh TYPE syucomm VALUE '&REFRESH'.

*---------------------------------------------------------------------

* types

*---------------------------------------------------------------------

TYPES :BEGIN OF ty_s_cdhdr.

INCLUDE TYPE cdhdr.

TYPES :checkbox TYPE xfeld,

END OF ty_s_cdhdr,

BEGIN OF ty_s_cdpos.

INCLUDE TYPE cdpos.

TYPES : checkbox TYPE xfeld,

END OF ty_s_cdpos.

*---------------------------------------------------------------------

* internal tables

*---------------------------------------------------------------------

DATA : gs_cdhdr TYPE cdhdr, " Change document header

* Layout for ALV

gs_layout TYPE slis_layout_alv,

* Change document header

t_cdhdr TYPE TABLE OF ty_s_cdhdr.

*---------------------------------------------------------------------

* selection screen design

*---------------------------------------------------------------------

SELECT-OPTIONS :

objectid FOR gs_cdhdr-objectid,

Username FOR gs_cdhdr-username DEFAULT sy-uname,

Date FOR gs_cdhdr-udate DEFAULT sy-datum OBLIGATORY.

SELECTION-SCREEN SKIP.

*---------------------------------------------------------------------

* start-of-selection .

*---------------------------------------------------------------------

START-OF-SELECTION.

PERFORM f_read_data.

*---------------------------------------------------------------------

* end-of-selection .

*---------------------------------------------------------------------

END-OF-SELECTION.

PERFORM f_display_cdhdr.

*---------------------------------------------------------------------

*Form f_read_data

*---------------------------------------------------------------------

FORM f_read_data.

*Read Change document header

SELECT * INTO TABLE t_cdhdr

FROM cdhdr

WHERE objectclas = 'INCOMINGINVOICE'

AND objectid IN objectid

* AND changenr IN s_chngnr

AND username IN Username

AND udate IN Date

* AND utime IN s_time

AND tcode = 'SU01'.

* AND planchngnr IN s_plncnr

* AND act_chngno IN s_chngno

* AND was_plannd IN s_wsplnd

* AND change_ind IN s_chngid.

ENDFORM. " F_READ_DATA

*---------------------------------------------------------------------

*

*Form f_display_cdhdr

*---------------------------------------------------------------------

FORM f_display_cdhdr.

DATA :ls_event_exit TYPE slis_event_exit,

lt_event_exit TYPE slis_t_event_exit.

gs_layout-zebra = c_x.

gs_layout-colwidth_optimize = c_x.

gs_layout-group_change_edit = c_x.

gs_layout-allow_switch_to_list = c_x.

gs_layout-box_fieldname = 'CHECKBOX'.

*Activate 'More' button

CLEAR ls_event_exit.

ls_event_exit-after = c_x.

ls_event_exit-ucomm = c_eb9. " More

APPEND ls_event_exit TO lt_event_exit.

*Activate refresh button

CLEAR ls_event_exit.

ls_event_exit-after = c_x.

ls_event_exit-ucomm = c_refresh. " Refresh

APPEND ls_event_exit TO lt_event_exit.

*Display ALV

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-cprog

i_callback_user_command = 'USER_COMMAND'

i_callback_pf_status_set = 'PF_STATUS_SET'

i_structure_name = 'CDHDR'

is_layout = gs_layout

it_event_exit = lt_event_exit

i_save = 'A'

TABLES

t_outtab = t_cdhdr.

ENDFORM. " F_DISPLAY_CDHDR

*---------------------------------------------------------------------

*

*FORM USER_COMMAND *

*---------------------------------------------------------------------

FORM user_command USING u_ucomm TYPE syucomm

us_selfield TYPE slis_selfield. "#EC CALLED

*Macro definition

DEFINE m_sort.

add 1 to ls_sort-spos.

ls_sort-fieldname = &1.

ls_sort-up = c_x.

append ls_sort to lt_sort.

END-OF-DEFINITION.

DATA :

ls_cdhdr TYPE ty_s_cdhdr,

ls_sort TYPE slis_sortinfo_alv,

lt_sort TYPE slis_t_sortinfo_alv,

*Change document items

lt_cdpos TYPE TABLE OF ty_s_cdpos.

CASE u_ucomm.

WHEN '&IC1' OR c_eb9.

PERFORM check_marked USING us_selfield.

*Read Change document items

LOOP AT t_cdhdr INTO ls_cdhdr WHERE checkbox = c_x.

SELECT * APPENDING TABLE lt_cdpos

FROM cdpos

WHERE objectclas = ls_cdhdr-objectclas

AND objectid = ls_cdhdr-objectid

AND changenr = ls_cdhdr-changenr.

ENDLOOP.

m_sort 'CHANGENR'.

*Display ALV

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-cprog

i_structure_name = 'CDPOS'

is_layout = gs_layout

it_sort = lt_sort

i_save = 'A'

TABLES

t_outtab = lt_cdpos.

WHEN c_refresh.

PERFORM f_read_data.

us_selfield-refresh = c_x.

ENDCASE.

ENDFORM. " USER_COMMAND

*---------------------------------------------------------------------

*Form CHECK_MARKED

*---------------------------------------------------------------------

*

*What has been marked in t_cdhdr

*---------------------------------------------------------------------

FORM check_marked USING us_selfield TYPE slis_selfield.

FIELD-SYMBOLS :

<cdhdr> TYPE ty_s_cdhdr.

READ TABLE t_cdhdr TRANSPORTING NO FIELDS

WITH KEY checkbox = c_x.

IF NOT sy-subrc IS INITIAL AND

NOT us_selfield-tabindex IS INITIAL.

READ TABLE t_cdhdr INDEX us_selfield-tabindex ASSIGNING <cdhdr>.

<cdhdr>-checkbox = c_x.

ENDIF.

ENDFORM. " CHECK_MARKED

*---------------------------------------------------------------------

*

*FORM PF_STATUS_SET *

*---------------------------------------------------------------------

FORM pf_status_set USING ut_extab TYPE slis_t_extab. "#EC CALLED

*Display 'Refresh' button and 'More' button

DELETE ut_extab WHERE fcode = c_refresh

OR fcode = c_eb9.

SET PF-STATUS 'STANDARD_FULLSCREEN' OF PROGRAM 'SAPLKKBL'

EXCLUDING ut_extab.

ENDFORM. " PF_STATUS_SET

Thanks.