You are on page 1of 6

INCLUDE zmm_reservation_data.

START-OF-SELECTION.
* To changes the reservation item dates through BAPI
perform reservation_getdat.
* To dispaly error and successful messages
PERFORM reservation_dispaly_alv .

*&---------------------------------------------------------------------*
*& Include
ZMM_RESERVATION_DATA
*&---------------------------------------------------------------------*
TABLES : resb.
TYPE-POOLS: slis .
************************************************************************
* Types declaration
************************************************************************
TYPES: BEGIN OF ty_rspos , " item number table declaration
rsnum TYPE resb-rsnum ,
rspos TYPE resb-rspos,
END OF ty_rspos.
TYPES: BEGIN OF ty_resb
, " Reservation numbers table declaration
rsnum TYPE resb-rsnum,
*
rspos TYPE resb-rspos,
END OF ty_resb.
TYPES: BEGIN OF ty_ret ,
rsnum TYPE resb-rsnum ,
rspos TYPE resb-rspos ,
mtype TYPE c,
msg(220) TYPE c,
END OF ty_ret.

" table declaration for error, success messages

************************************************************************
* Internal Tables for Reservation, item and return message
************************************************************************
DATA: lt_resb TYPE STANDARD TABLE OF ty_resb,
ls_resb TYPE ty_resb,
lt_rspos TYPE STANDARD TABLE OF ty_rspos,
ls_rspos TYPE ty_rspos ,
lt_ret TYPE STANDARD TABLE OF ty_ret,
ls_ret TYPE ty_ret.
DATA: lv_repid TYPE sy-repid.
DATA: lt_fieldcat TYPE slis_t_fieldcat_alv,

ls_fieldcat TYPE slis_fieldcat_alv.


************************************************************************
* BAPI Internal Tables
************************************************************************
DATA:
DATA:
DATA:
DATA:
DATA:
DATA:

lt_reservation TYPE TABLE OF bapi2093_res_item_change.


ls_reservation TYPE bapi2093_res_item_change.
lt_return TYPE TABLE OF bapiret2 .
ls_return TYPE bapiret2.
lt_reservationx TYPE TABLE OF bapi2093_res_item_changex .
ls_reservationx TYPE bapi2093_res_item_changex .

************************************************************************
* Selection-Screen for Reservation Numbers and requiested date
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_rsnum FOR resb-rsnum OBLIGATORY .
SELECTION-SCREEN SKIP.
PARAMETERS: p_bdter TYPE resb-bdter OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
*&---------------------------------------------------------------------*
*&
Form RESERVATION_DISPALY_ALV
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM reservation_dispaly_alv .
*PERFORM
*PERFORM
*PERFORM
*PERFORM

CREATE_FCAT
CREATE_FCAT
CREATE_FCAT
CREATE_FCAT

USING
USING
USING
USING

'1'
'2'
'3'
'4'

'rsnum' 'it_ret' '10' 'Reservation No' .


'rspos' 'it_ret' '10' 'Iteam No' .
'MTYPE' 'it_ret' '10' 'MESSAGE TYPE' .
'MSG' 'it_ret' '220' 'MESSAGE TEXT' .

ls_fieldcat-col_pos = 1.
ls_fieldcat-fieldname = 'RSNUM'.
ls_fieldcat-tabname = 'IT_RET'.
ls_fieldcat-outputlen = '10'.
ls_fieldcat-seltext_m = text-002. " Reservation No
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR ls_fieldcat .
ls_fieldcat-col_pos = 2.
ls_fieldcat-fieldname = 'RSPOS'.
ls_fieldcat-tabname = 'IT_RET'.

ls_fieldcat-seltext_m = text-003 . "Item No.


ls_fieldcat-outputlen = '10'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR ls_fieldcat .
ls_fieldcat-col_pos = 3.
ls_fieldcat-fieldname = 'MTYPE'.
ls_fieldcat-tabname = 'IT_RET'.
ls_fieldcat-seltext_m = text-004 . " MESSAGE TYPE.
ls_fieldcat-outputlen = '10'.
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR ls_fieldcat .
ls_fieldcat-col_pos = 4.
ls_fieldcat-fieldname = 'MSG'.
ls_fieldcat-tabname = 'IT_RET'.
ls_fieldcat-seltext_m = text-005.
ls_fieldcat-outputlen = '220'.

"MESSAGE TEXT .

APPEND ls_fieldcat TO lt_fieldcat.


CLEAR ls_fieldcat .

*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'


EXPORTING
I_INTERFACE_CHECK
= ' '
I_BYPASSING_BUFFER
= ' '
I_BUFFER_ACTIVE
= ' '
i_callback_program
= lv_repid
I_CALLBACK_PF_STATUS_SET
= ' '
I_CALLBACK_USER_COMMAND
= ' '
I_CALLBACK_TOP_OF_PAGE
= ' '
I_CALLBACK_HTML_TOP_OF_PAGE
= ' '
I_CALLBACK_HTML_END_OF_LIST
= ' '
I_STRUCTURE_NAME
=
I_BACKGROUND_ID
= ' '
I_GRID_TITLE
=
I_GRID_SETTINGS
=
IS_LAYOUT
=
it_fieldcat
= lt_fieldcat
IT_EXCLUDING
=
IT_SPECIAL_GROUPS
=
IT_SORT
=
IT_FILTER
=
IS_SEL_HIDE
=
I_DEFAULT
= 'X'
I_SAVE
= ' '
IS_VARIANT
=
IT_EVENTS
=
IT_EVENT_EXIT
=
IS_PRINT
=

*
IS_REPREP_ID
=
*
I_SCREEN_START_COLUMN
= 0
*
I_SCREEN_START_LINE
= 0
*
I_SCREEN_END_COLUMN
= 0
*
I_SCREEN_END_LINE
= 0
*
I_HTML_HEIGHT_TOP
= 0
*
I_HTML_HEIGHT_END
= 0
*
IT_ALV_GRAPHICS
=
*
IT_HYPERLINK
=
*
IT_ADD_FIELDCAT
=
*
IT_EXCEPT_QINFO
=
*
IR_SALV_FULLSCREEN_ADAPTER
=
* IMPORTING
*
E_EXIT_CAUSED_BY_CALLER
=
*
ES_EXIT_CAUSED_BY_USER
=
TABLES
t_outtab
= lt_ret
EXCEPTIONS
program_error
= 1
OTHERS
= 2
.
IF sy-subrc <> 0. " #EC * .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.
" RESERVATION_DISPALY_ALV
*&---------------------------------------------------------------------*
*&
Form RESERVATION_GETDAT
*&---------------------------------------------------------------------*
*
updating reservation items dates by selection screen inputs
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM reservation_getdat .
* fetch reservation, item numbers from resb by avoiding deleted items
SELECT rsnum rspos FROM resb
INTO TABLE lt_rspos WHERE rsnum IN s_rsnum AND xloek NE 'X'
.
lt_resb[] = lt_rspos[].
SORT lt_resb BY rsnum.
DELETE ADJACENT DUPLICATES FROM lt_resb COMPARING rsnum .
* looping reservation numbers
LOOP AT lt_resb INTO ls_resb.
REFRESH: lt_reservation,
lt_reservationx,
lt_return.
* looping item numbers for particular reservation number
LOOP AT lt_rspos INTO ls_rspos WHERE rsnum = ls_resb-rsnum.

ls_reservation-res_item = ls_rspos-rspos .
" passing values into bapi internal tables
ls_reservation-req_date = p_bdter .
APPEND ls_reservation TO lt_reservation .
CLEAR ls_reservation .
ls_reservationx-res_item = ls_rspos-rspos.
ls_reservationx-req_date = 'X'.
APPEND ls_reservationx TO lt_reservationx .
CLEAR ls_reservationx.
* bapi to change the date for reservation item numbers

*
*

*
*

CALL FUNCTION 'BAPI_RESERVATION_CHANGE'


EXPORTING
reservation
= ls_resb-rsnum
TESTRUN
=
ATPCHECK
=
TABLES
reservationitems_changed
= lt_reservation
reservationitems_changedx
= lt_reservationx
RESERVATIONITEMS_NEW
=
return
= lt_return
EXTENSIONIN
=
.

To update changes in data base


LOOP AT lt_return INTO ls_return.
IF ls_return-type <> 'E' . " AND ls_return-type <> 'A' AND ls_returntype <> 'W'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait
= 'X'
*
IMPORTING
*
RETURN
=
.
EXIT.
ENDIF.
CLEAR: ls_return.
ENDLOOP.
CLEAR ls_return.
* to Read error message
READ TABLE lt_return INTO ls_return WITH KEY type = 'E' .
"
IF sy-subrc EQ 0 .
ls_ret-rsnum = ls_resb-rsnum .
ls_ret-rspos = ls_rspos-rspos .

ls_ret-mtype = 'E' .
ls_ret-msg = ls_return-message .
APPEND ls_ret TO lt_ret .
CLEAR ls_ret.
ELSE .
CLEAR ls_return.
* To read successful messages
READ TABLE lt_return INTO ls_return INDEX 2 .
* READ TABLE i_return into wa_return WITH KEY TYPE = 'S' .
ls_ret-rsnum = ls_resb-rsnum .
ls_ret-rspos = ls_rspos-rspos .
ls_ret-mtype = ls_return-type.
ls_ret-msg = ls_return-message .
APPEND ls_ret TO lt_ret .
CLEAR ls_ret.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDFORM.
" RESERVATION_GETDAT
*&---------------------------------------------------------------------*
*&
Form CREATE_FCAT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_0163
col position
*
-->P_0164
field name
*
-->P_0165
Internal table
*
-->P_0166
output length
*
-->P_0167
selected text for field
*----------------------------------------------------------------------*
*form CREATE_FCAT using
value(p_0163)
*
value(p_0164)
*
value(p_0165)
*
value(p_0166)
*
value(p_0167).
*
* ls_fieldcat-col_pos = p_0163.
* ls_fieldcat-fieldname = p_0164.
* ls_fieldcat-tabname = p_0165.
* ls_fieldcat-outputlen = p_0166.
* ls_fieldcat-seltext_m = p_0167 .
*
* APPEND ls_fieldcat TO lt_fieldcat.
* CLEAR ls_fieldcat .
*
*endform.
" CREATE_FCAT

You might also like