Skip to Content
0
Former Member
Nov 25, 2013 at 03:57 PM

Notification creation query

36 Views

Hello Experts,

I have created a module pool program to create fast entry service notification creation. I have completed all the requirements, when user press SAVE button on standard tool bar it creates new notification and deliver a number in status bar. I managed to get all the requirements but not able to create notification so if anybody have any idea please share it with me here is the code and screen shot for program.

PROGRAM zcs_servnote.

TABLES: zcs_t_servnote,KNA1,T356_T,CRHD_V1,QPCT.

DATA: g_str_servnote TYPE zcs_t_servnote,

g_str_custname TYPE KNA1,

g_str_priotxt TYPE T356_T,

* g_str_workctr TYPE CRHD_V1,

g_str_category TYPE QPCT.

DATA: ok_code TYPE sy-ucomm,

save_ok LIKE ok_code.

DATA: g_rcl_customcontainer TYPE REF TO cl_gui_custom_container,

g_rcl_texteditor TYPE REF TO cl_gui_textedit,

g_sys_repid LIKE sy-repid,

l_text TYPE string,

l_cursor TYPE ZCS_T_SERVNOTE.

CONSTANTS: g_con_linelength TYPE i VALUE 256.

INCLUDE zcs_servnote_status_0100o01.

INCLUDE zcs_servnote_user_command_0i01.

PBO:-

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

***INCLUDE ZCS_SERVNOTE_STATUS_0100O01 .

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

*&---------------------------------------------------------------------*

*& Module STATUS_0100 OUTPUT

*&---------------------------------------------------------------------*

* text

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

MODULE status_0100 OUTPUT.

SET PF-STATUS 'STATUS_100'.

SET TITLEBAR 'TITLE_100'.

zcs_t_servnote-qmart = 'Y1'.

QPCT-CODEGRUPPE = 'MODULE2'.

zcs_t_servnote-plant = '7000'.

CASE l_cursor.

WHEN 'ZCS_T_SERVNOTE-QMTXT'.

SET CURSOR FIELD 'KNA1-KUNNR'.

WHEN 'KNA1-KUNNR'.

SET CURSOR FIELD 'ZCS_T_SERVNOTE-BSTNK'.

WHEN 'ZCS_T_SERVNOTE-BSTNK'.

SET CURSOR FIELD 'QPCT-CODE'.

WHEN 'QPCT-CODE'.

SET CURSOR FIELD 'ZCS_T_SERVNOTE-PARNR'.

WHEN 'ZCS_T_SERVNOTE-PARNR'.

SET CURSOR FIELD 'ZCS_T_SERVNOTE-ARBPL'.

WHEN 'ZCS_T_SERVNOTE-ARBPL'.

SET CURSOR FIELD 'T356_T-PRIOK'.

WHEN 'T356_T-PRIOK'.

SET CURSOR FIELD 'ZCS_T_SERVNOTE-BNAME'.

ENDCASE.

IF g_rcl_texteditor IS INITIAL.

g_sys_repid = sy-repid.

CREATE OBJECT g_rcl_customcontainer

EXPORTING

container_name = 'Z_CUSTOM_CONTAINER'

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5.

CREATE OBJECT g_rcl_texteditor

EXPORTING

parent = g_rcl_customcontainer

wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position

wordwrap_position = g_con_linelength

wordwrap_to_linebreak_mode = cl_gui_textedit=>true.

CALL METHOD g_rcl_texteditor->set_toolbar_mode

EXPORTING

toolbar_mode = cl_gui_textedit=>false.

CALL METHOD g_rcl_texteditor->set_statusbar_mode

EXPORTING

statusbar_mode = cl_gui_textedit=>false.

ENDIF.

LOOP AT SCREEN.

IF zcs_t_servnote-parnr IS NOT INITIAL.

DATA: first_name LIKE zcs_t_servnote-fname,

last_name LIKE zcs_t_servnote-lname.

SELECT SINGLE fname lname FROM zcs_t_servnote INTO (first_name,last_name).

IF sy-subrc = 0.

CONCATENATE first_name last_name INTO zcs_t_servnote-contact SEPARATED BY space.

ENDIF.

ENDIF.

ENDLOOP.

LOOP AT SCREEN.

IF zcs_t_servnote-bname IS NOT INITIAL.

DATA: f_name LIKE zcs_t_servnote-name1,

l_name LIKE zcs_t_servnote-name2.

SELECT SINGLE name1 name2 FROM zcs_t_servnote INTO (f_name,l_name).

IF sy-subrc = 0.

CONCATENATE f_name l_name INTO zcs_t_servnote-pername SEPARATED BY space.

ENDIF.

ENDIF.

ENDLOOP.

LOOP AT SCREEN.

IF screen-group1 = 'GR1'.

screen-required = '2'. "set as mandatory

ENDIF.

MODIFY SCREEN.

ENDLOOP.

ENDMODULE. " STATUS_0100 OUTPUT

*&---------------------------------------------------------------------*

*& Module CLEAR_OK_CODE OUTPUT

*&---------------------------------------------------------------------*

* text

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

MODULE clear_ok_code OUTPUT.

save_ok = ok_code.

CLEAR ok_code.

CASE save_ok.

WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " CLEAR_OK_CODE OUTPUT

PAI:-

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

***INCLUDE ZCS_SERVNOTE_USER_COMMAND_0I01 .

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

*&---------------------------------------------------------------------*

*& Module USER_COMMAND_0100 INPUT

*&---------------------------------------------------------------------*

* text

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

MODULE user_command_0100 INPUT.

DATA: r_str_return TYPE bapiret2,

l_str_number TYPE bapi2080_nothdre-notif_no,

l_str_notifheader TYPE bapi2080_nothdri,

l_str_partner TYPE bapi2080_notpartnri,

l_str_notif_type TYPE bapi2080-notif_type VALUE 'Y1',

l_str_notifheader_export TYPE bapi2080_nothdre,

l_str_notifplant TYPE bapi2080_notitemi,

l_str_notif TYPE bapi2080,

l_str_longtexts TYPE bapi2080_notfulltxti-text_line.

DATA: l_tab_longtexts TYPE STANDARD TABLE OF bapi2080_notfulltxti,

l_tab_partner TYPE STANDARD TABLE OF bapi2080_notpartnri,

l_tab_return TYPE STANDARD TABLE OF bapiret2.

GET CURSOR FIELD l_cursor.

ok_code = sy-ucomm.

CASE ok_code.

WHEN 'SAVE'.

l_str_notifheader-refobjecttype = 'BUS2080'.

l_str_notifheader-short_text = zcs_t_servnote-qmtxt.

l_str_notifheader-priority = T356_T-priok.

l_str_notifheader-planplant = zcs_t_servnote-plant.

l_str_notifheader-pm_wkctr = zcs_t_servnote-arbpl.

l_str_notifheader-purch_no_c = zcs_t_servnote-bstnk.

l_str_notifheader-breakdown = zcs_t_servnote-msaus.

l_str_notif-contact = zcs_t_servnote-parnr.

l_str_notifplant-dl_codegrp = QPCT-CODEGRUPPE.

l_str_notifplant-dl_code = QPCT-CODE.

l_str_notifheader-strmlfndate = sy-datum.

l_str_notifheader-strmlfntime = sy-uzeit.

l_str_partner-partn_role = 'AG'.

l_str_partner-partner = KNA1-KUNNR.

APPEND l_str_partner TO l_tab_partner.

l_str_partner-partn_role = 'AP'.

l_str_partner-partner = KNA1-KUNNR.

APPEND l_str_partner TO l_tab_partner.

l_str_partner-partn_role = 'YY'.

l_str_partner-partner = zcs_t_servnote-bname.

APPEND l_str_partner TO l_tab_partner.

* Saving Long Text into Table

CALL METHOD g_rcl_texteditor->get_textstream

EXPORTING

only_when_modified = cl_gui_textedit=>true

IMPORTING

text = l_text

EXCEPTIONS

error_cntl_call_method = 1

not_supported_by_gui = 2

OTHERS = 3.

l_str_longtexts = l_text.

APPEND l_str_longtexts TO l_tab_longtexts.

* Service Notification Creation

CALL FUNCTION 'BAPI_SERVNOT_CREATE'

EXPORTING

notif_type = l_str_notif_type

notifheader = l_str_notifheader

IMPORTING

notifheader_export = l_str_notifheader_export

TABLES

notifpartnr = l_tab_partner

return = l_tab_return

longtexts = l_tab_longtexts.

* Generation of Success Message

l_str_number = l_str_notifheader_export-notif_no.

IF l_str_number IS NOT INITIAL.

MESSAGE s000(zcs) WITH l_str_number.

CALL FUNCTION 'BAPI_SERVNOT_SAVE'

EXPORTING

number = l_str_number.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

* Clears screen for next entry

PERFORM zcs_clearscreen.

* Saving Long Text into Table

CALL METHOD g_rcl_texteditor->get_textstream

EXPORTING

only_when_modified = cl_gui_textedit=>true

IMPORTING

text = l_text

EXCEPTIONS

error_cntl_call_method = 1

not_supported_by_gui = 2

OTHERS = 3.

l_str_longtexts = l_text.

APPEND l_str_longtexts TO l_tab_longtexts.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDIF.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

*&---------------------------------------------------------------------*

*& Module EXIT INPUT

*&---------------------------------------------------------------------*

* text

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

MODULE exit INPUT.

ok_code = sy-ucomm.

CASE ok_code.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'CANCEL'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " EXIT INPUT

*&---------------------------------------------------------------------*

*& Module ZCS_READKUNUM INPUT

*&---------------------------------------------------------------------*

* text

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

MODULE zcs_readkunum INPUT.

ENDMODULE. " ZCS_READKUNUM INPUT

*&---------------------------------------------------------------------*

*& Module MESG_MANDATOR INPUT

*&---------------------------------------------------------------------*

* text

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

*Making fields Madatory dynamically

MODULE zcs_mandator INPUT.

CHECK sy-ucomm EQ 'SAVE'.

IF zcs_t_servnote-qmtxt IS INITIAL.

MESSAGE 'Please enter description' TYPE 'E'.

ENDIF.

IF QPCT-CODE IS INITIAL.

MESSAGE 'Please enter Categorization' TYPE 'E'.

ENDIF.

* IF zcs_t_servnote-contact IS INITIAL.

* MESSAGE 'Please enter cutomer contact person' TYPE 'E'.

* ENDIF.

IF zcs_t_servnote-arbpl IS INITIAL.

MESSAGE 'Please enter work center' TYPE 'E'.

ENDIF.

IF zcs_t_servnote-plant IS INITIAL.

MESSAGE 'Please enter Plant' TYPE 'E'.

ENDIF.

IF T356_T-priok IS INITIAL.

MESSAGE 'Please enter Priority' TYPE 'E'.

ENDIF.

IF zcs_t_servnote-bname IS INITIAL.

MESSAGE 'Please enter Person responsible' TYPE 'E'.

ENDIF.

ENDMODULE. " MESG_MANDATOR INPUT

*&---------------------------------------------------------------------*

*& Form ZCS_CLEARSCREEN

*&---------------------------------------------------------------------*

* text

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

* --> p1 text

* <-- p2 text

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

FORM zcs_clearscreen .

CLEAR: zcs_t_servnote-qmtxt.

CLEAR: zcs_t_servnote-kunum.

CLEAR: zcs_t_servnote-cust_list.

CLEAR: zcs_t_servnote-oteil.

CLEAR: zcs_t_servnote-priok.

CLEAR: zcs_t_servnote-contact.

CLEAR: zcs_t_servnote-arbpl.

CLEAR: zcs_t_servnote-priokx.

CLEAR: zcs_t_servnote-bname.

CLEAR: zcs_t_servnote-pername.

ENDFORM. " ZCS_CLEARSCREEN4.

*&---------------------------------------------------------------------*

*& Module ZCS_READCUSTNO INPUT

*&---------------------------------------------------------------------*

* text

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

MODULE ZCS_READCUSTNO INPUT.

SELECT SINGLE * FROM KNA1 INTO g_str_custname

WHERE kunnr EQ KNA1-kunnr.

IF sy-subrc EQ 0.

KNA1 = g_str_custname.

ENDIF.

* LOOP AT SCREEN.

IF KNA1-KUNNR EQ ZCS_T_SERVNOTE-KUNUM.

SELECT SINGLE * FROM zcs_t_servnote INTO g_str_servnote

WHERE kunum EQ zcs_t_servnote-kunum.

IF sy-subrc EQ 0.

zcs_t_servnote-kunum = g_str_servnote-kunum.

zcs_t_servnote-cust_list = g_str_servnote-cust_list.

zcs_t_servnote-bstnk = g_str_servnote-bstnk.

zcs_t_servnote-oteil = g_str_servnote-oteil.

zcs_t_servnote-parnr = g_str_servnote-parnr.

zcs_t_servnote-contact = g_str_servnote-contact.

zcs_t_servnote-msaus = g_str_servnote-msaus.

zcs_t_servnote-arbpl = g_str_servnote-arbpl.

zcs_t_servnote-bname = g_str_servnote-bname.

ENDIF.

ENDIF.

* ENDLOOP.

ENDMODULE. " ZCS_READCUSTNO INPUT

*&---------------------------------------------------------------------*

*& Module ZCS_PRIOTXT INPUT

*&---------------------------------------------------------------------*

* text

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

MODULE ZCS_PRIOTXT INPUT.

SELECT SINGLE * FROM T356_T INTO g_str_priotxt

WHERE priok EQ T356_T-priok AND ARTPR EQ 'AC' AND SPRAS EQ 'EN'.

IF sy-subrc EQ 0.

T356_T = g_str_priotxt.

ENDIF.

ENDMODULE. " ZCS_PRIOTXT INPUT

*&---------------------------------------------------------------------*

*& Module ZCS_WORKCTR INPUT

*&---------------------------------------------------------------------*

* text

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

*MODULE ZCS_WORKCTR INPUT.

* SELECT SINGLE * FROM CRHD_V1 INTO g_str_workctr

* WHERE ARBPL EQ CRHD_V1-ARBPL.

* IF sy-subrc EQ 0.

* CRHD_V1 = g_str_workctr.

* ENDIF.

*ENDMODULE. " ZCS_WORKCTR INPUT

*&---------------------------------------------------------------------*

*& Module ZCS_CATEGORY INPUT

*&---------------------------------------------------------------------*

* text

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

MODULE ZCS_CATEGORY INPUT.

SELECT SINGLE * FROM QPCT INTO g_str_category

WHERE CODE EQ QPCT-CODE.

IF sy-subrc EQ 0.

QPCT = g_str_category.

ENDIF.

ENDMODULE. " ZCS_CATEGORY INPUT

FLOW LOGIC:-

process before output.

module status_0100.

module set_cursor.

process after input.

module exit at exit-command.

chain.

field zcs_t_servnote-qmtxt.

field kna1-kunnr.

* field zcs_t_servnote-kunum.

* field zcs_t_servnote-otgrp.

* field zcs_t_servnote-oteil.

* field zcs_t_servnote-contact.

field zcs_t_servnote-arbpl.

field zcs_t_servnote-plant.

* field zcs_t_servnote-priok.

field zcs_t_servnote-bname.

module zcs_mandator.

endchain.

field KNA1-KUNNR module zcs_readcustno on request.

field T356_T-PRIOK module zcs_priotxt on request.

* field CRHD_V1-ARBPL module zcs_workctr on request.

field QPCT-CODE module zcs_category on request.

* field ZCS_V_WRKCTR-ARBPL module zcs_wrkctr on request.

module user_command_0100.

Attachments

SCREEN.jpg (87.1 kB)