on 2024 Aug 07 12:22 PM
CONDITION: Select the checkbox and input XYZ in material description and click on the Check Data button.
A pop up must appear as “ Input is invalid”.
I WANT IT TO PROCESS AS WHEN CHECHBOX IS TICKED AND IF WE ENTER XYZ IN MATERIAL DESCRIPTION IT SHOULD GIVE A MESSAGE AFTER CLICKING ON CHECKDATA BUTTON FROM PF STATUS
MY CODE FOR REFFERENCE:
*&---------------------------------------------------------------------*
*& Report Z_TASK4
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Z_TASK4.
TABLES: MARA, MARC, MARD, MAKT.
TYPE-POOLS: SLIS.
TYPES: BEGIN OF TY_FINAL,
MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
MTART TYPE MARA-MTART,
WERKS TYPE MARC-WERKS,
LGORT TYPE MARD-LGORT,
XCHAR TYPE MARC-XCHAR,
MAKTX TYPE MAKT-MAKTX,
CHECK TYPE C,
LINE_COLOR(4),
COL_FIELD TYPE SLIS_T_SPECIALCOL_ALV,
END OF TY_FINAL.
TYPES: BEGIN OF TY_MARA,
MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
MTART TYPE MARA-MTART,
END OF TY_MARA.
types : begin of ty_makt,
matnr type makt-matnr,
maktx type makt-maktx,
end of ty_makt.
types : begin of ty_marc,
matnr type marc-matnr,
werks type marc-werks,
xchar type marc-xchar,
end of ty_marc.
types : begin of ty_mard,
matnr type mard-matnr,
werks type mard-werks,
lgort type mard-lgort,
end of ty_mard.
types : begin of ty_mtart,
mtart type mara-mtart,
end of ty_mtart.
types : begin of ty_matnr,
matnr type mara-matnr,
end of ty_matnr.
*DATA DECLARATIONS
DATA: LS_COL_FIELD TYPE SLIS_SPECIALCOL_ALV.
DATA: LT_FINAL TYPE STANDARD TABLE OF TY_FINAL,
LS_FINAL TYPE TY_FINAL.
data :lt_mara type standard table of ty_mara,
ls_mara type ty_mara.
data :lt_makt type standard table of ty_makt,
ls_makt type ty_makt.
data :lt_marc type standard table of ty_marc,
ls_marc type ty_marc.
data :lt_mard type standard table of ty_mard,
ls_mard type ty_mard.
DATA: LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: LS_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA : LT_HEADER TYPE SLIS_T_LISTHEADER,
LS_HEADER TYPE SLIS_LISTHEADER.
DATA: POS TYPE I,
LV_TIME(6) TYPE C,
LV_DATE(8) TYPE C.
START-OF-SELECTION.
PERFORM GET_MATERIAL.
PERFORM GET_PLANT.
PERFORM GET_STORAGE.
PERFORM GET_DESCRIPTION.
PERFORM PREPARE_OUTPUT.
END-OF-SELECTION.
PERFORM GET_FIELDCAT.
PERFORM GET_LAYOUT.
PERFORM DISPLAY_ALV.
PERFORM TOP_OF_PAGE.
*&---------------------------------------------------------------------*
*& Form GET_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_fieldcat .
CLEAR LT_FIELDCAT.
CLEAR LS_FIELDCAT.
POS = POS + 1.
LS_FIELDCAT-fieldname = 'CHECK'.
*LS_FIELDCAT-seltext_l = 'SELECT'.
LS_FIELDCAT-col_pos = POS.
LS_FIELDCAT-edit = 'X'.
LS_FIELDCAT-checkbox = 'X'.
APPEND LS_FIELDCAT TO LT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-fieldname = 'MATNR'.
LS_FIELDCAT-seltext_l = 'MATERIAL NO.'.
LS_FIELDCAT-HOTSPOT = 'X'.
LS_FIELDCAT-col_pos = POS.
APPEND LS_FIELDCAT TO LT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-fieldname = 'WERKS'.
LS_FIELDCAT-seltext_l = 'PLANT'.
LS_FIELDCAT-col_pos = POS.
APPEND LS_FIELDCAT TO LT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-fieldname = 'LGORT'.
LS_FIELDCAT-seltext_l = 'STORAGE LOCATION'.
LS_FIELDCAT-col_pos = POS.
APPEND LS_FIELDCAT TO LT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-fieldname = 'MTART'.
LS_FIELDCAT-seltext_l = 'MATERIAL TYPE'.
LS_FIELDCAT-col_pos = POS.
APPEND LS_FIELDCAT TO LT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-fieldname = 'XCHAR'.
LS_FIELDCAT-seltext_l = 'BATCH NO.'.
LS_FIELDCAT-col_pos = POS.
LS_FIELDCAT-emphasize = 'C500'.
APPEND LS_FIELDCAT TO LT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-fieldname = 'MAKTX'.
LS_FIELDCAT-seltext_l = 'MATERIAL DESCRIPTION'.
LS_FIELDCAT-col_pos = POS.
LS_FIELDCAT-edit = 'X'.
APPEND LS_FIELDCAT TO LT_FIELDCAT.
CLEAR LS_FIELDCAT.
ENDFORM. " GET_FIELDCAT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_alv .
DATA: lt_events TYPE slis_t_event,
ls_event TYPE slis_alv_event.
CLEAR ls_event.
ls_event-name = 'PF_STATUS_SET'.
ls_event-form = 'PF_STATUS'.
APPEND ls_event TO lt_events.
CLEAR ls_event.
ls_event-name = 'USER_COMMAND'.
ls_event-form = 'USER_COMMAND'.
APPEND ls_event TO lt_events.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = '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 = LS_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 = LT_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_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM. " DISPLAY_ALV
*&---------------------------------------------------------------------*
*& Form GET_LAYOUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_layout .
LS_LAYOUT-zebra = 'X'.
ls_layout-colwidth_optimize = 'X'.
LS_LAYOUT-info_fieldname = 'LINE_COLOR'.
LS_LAYOUT-coltab_fieldname = 'COL_FIELD'.
ENDFORM. " GET_LAYOUT
*&---------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM TOP_OF_PAGE.
CALL FUNCTION 'TIME_CHAR_CONVERSION'
EXPORTING
input = SY-UZEIT
IMPORTING
TIMESTR = LV_TIME
.
CLEAR LT_HEADER.
CLEAR LS_HEADER.
LS_HEADER-typ = 'H'.
LS_HEADER-INFO = 'MATERIAL DETAILS LIST'.
APPEND LS_HEADER TO LT_HEADER.
CLEAR LS_HEADER.
LS_HEADER-typ = 'S'.
LS_HEADER-KEY = 'REPORT:'.
LS_HEADER-info = SY-REPID.
APPEND LS_HEADER TO LT_HEADER.
CLEAR LS_HEADER.
LS_HEADER-typ = 'S'.
LS_HEADER-KEY = 'USER:'.
LS_HEADER-info = SY-UNAME.
APPEND LS_HEADER TO LT_HEADER.
CLEAR LS_HEADER.
LS_HEADER-typ = 'S'.
LS_HEADER-KEY = 'DATE:'.
LS_HEADER-info = SY-DATUM.
APPEND LS_HEADER TO LT_HEADER.
CLEAR LS_HEADER.
LS_HEADER-typ = 'S'.
LS_HEADER-KEY = 'TIME:'.
LS_HEADER-info = LV_TIME.
APPEND LS_HEADER TO LT_HEADER.
CLEAR LS_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = LT_HEADER
* I_LOGO =
* I_END_OF_LIST_GRID =
* I_ALV_FORM =
.
ENDFORM. " TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form GET_EVENT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
*FORM get_event .
*
*
*ENDFORM. " GET_EVENT
*&---------------------------------------------------------------------*
*& Form GET_MATERIAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_material .
SELECT MATNR ERSDA ERNAM MTART
FROM MARA
INTO TABLE LT_MARA.
IF SY-SUBRC IS INITIAL.
SORT LT_MARA BY MATNR.
ENDIF.
ENDFORM. " GET_MATERIAL
*&---------------------------------------------------------------------*
*& Form GET_PLANT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_plant .
IF LT_MARA IS NOT INITIAL.
SELECT MATNR WERKS XCHAR
FROM MARC
INTO TABLE LT_MARC
FOR ALL ENTRIES IN LT_MARA
WHERE MATNR = LT_MARA-MATNR.
IF SY-SUBRC IS INITIAL.
SORT LT_MARC BY MATNR.
ENDIF.
ENDIF.
ENDFORM. " GET_PLANT
*&---------------------------------------------------------------------*
*& Form GET_STORAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_storage .
IF LT_MARC IS NOT INITIAL.
SELECT MATNR WERKS LGORT
FROM MARD
INTO TABLE LT_MARD
FOR ALL ENTRIES IN LT_MARC
WHERE MATNR = LT_MARC-MATNR
AND WERKS = LT_MARC-WERKS.
IF SY-SUBRC IS INITIAL.
SORT LT_MARD BY MATNR.
ENDIF.
ENDIF.
ENDFORM. " GET_STORAGE
*&---------------------------------------------------------------------*
*& Form GET_DESCRIPTION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_description .
IF LT_MARA IS NOT INITIAL.
SELECT MATNR MAKTX
FROM MAKT
INTO TABLE LT_MAKT
FOR ALL ENTRIES IN LT_MARA
WHERE MATNR = LT_MARA-MATNR
AND SPRAS = 0.
IF SY-SUBRC IS INITIAL.
SORT LT_MAKT BY MATNR.
ENDIF.
ENDIF.
ENDFORM. " GET_DESCRIPTION
*&---------------------------------------------------------------------*
*& Form PREPARE_OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM prepare_output .
LOOP AT LT_MARA INTO LS_MARA.
LS_FINAL-MATNR = LS_MARA-MATNR.
LS_FINAL-ERSDA = LS_MARA-MATNR.
LS_FINAL-ERNAM = LS_MARA-ERNAM.
LS_FINAL-MTART = LS_MARA-MTART.
READ TABLE LT_MAKT INTO LS_MAKT
WITH KEY MATNR = LS_MARA-MATNR.
IF SY-SUBRC IS INITIAL.
LS_FINAL-MAKTX = LS_MAKT-MAKTX.
ENDIF.
read table lt_marc into ls_marc
with key matnr = ls_mara-matnr.
if sy-subrc = 0.
ls_final-werks = ls_marc-werks.
ls_final-xchar = ls_marc-xchar.
endif.
read table lt_mard into ls_mard
with key matnr = ls_marc-matnr.
if sy-subrc = 0.
ls_final-lgort = ls_mard-lgort.
endif.
APPEND LS_FINAL TO LT_FINAL.
CLEAR LS_FINAL.
ENDLOOP.
LOOP AT LT_FINAL INTO LS_FINAL.
IF LS_FINAL-MTART = 'ROH'.
clear LS_COL_FIELD.
LS_COL_field-fieldname = 'MTART'.
LS_COL_field-color-col = 6.
append ls_COL_field to ls_final-COL_FIELD.
modify lt_final from ls_final .
endif.
ENDLOOP.
ENDFORM. " PREPARE_OUTPUT
FORM PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD' EXCLUDING RT_EXTAB.
APPEND '&CHECK_DATA' TO rt_extab.
APPEND 'EXIT' TO rt_extab.
ENDFORM.
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&CHECK_DATA'.
PERFORM CHECK_DATA.
WHEN 'EXIT' OR 'CANCEL'.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN '&IC1'.
READ TABLE LT_FINAL INTO LS_FINAL INDEX RS_SELFIELD-TABINDEX.
CASE RS_SELFIELD-fieldname.
WHEN 'MATNR'.
IF LS_FINAL-MATNR IS NOT INITIAL.
SET PARAMETER ID 'MAT' FIELD LS_FINAL-MATNR.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDCASE.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CHECK_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM check_data .
* DATA: LV_INVALID TYPE C.
*
* LOOP AT LT_FINAL INTO LS_FINAL WHERE CHECK = 'X' AND MAKTX = 'XYZ'.
* LV_INVALID = 'X'.
* EXIT.
* ENDLOOP.
*
* IF LV_INVALID = 'X'.
* MESSAGE 'INPUT IS INVALID' TYPE 'I'.
* ENDIF.
MESSAGE 'INPUT IS INVALID' TYPE 'I'.
ENDFORM. " CHECK_DATA
THIS IS HOW OUTPUT SCREEN LOOKS
THE BUTTON IS CHECKDATA
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
70 | |
10 | |
10 | |
10 | |
10 | |
8 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.