Selection Screen Logic in Ibargam

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 26

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

*& Report ZPLANNING_VIEW


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zplanning_view NO STANDARD PAGE HEADING.
TYPE-POOLS: truxs,esp1.
DATA: es_row_no TYPE lvc_s_roid.
TYPES: BEGIN OF ty_output,
matnr TYPE matnr,
vkorg TYPE vkorg,
vtweg TYPE vtweg,
werks TYPE werks_d,
dismm TYPE marc-dismm,
sobst(5) TYPE c,
prmod TYPE mpop-prmod,
perkz TYPE marc-perkz,
bwscl TYPE marc-bwscl,
mtvfp TYPE marc-mtvfp,
END OF ty_output.
TYPES: BEGIN OF ty_matnr,
matnr TYPE matnr,
END OF ty_matnr.
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA: it_output TYPE STANDARD TABLE OF ty_output,
wa_output TYPE ty_output,
wa_output1 TYPE ty_output.
DATA: wa_layout TYPE lvc_s_layo,
it_fieldcat TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat,
c_alv TYPE REF TO cl_gui_alv_grid,
c_container TYPE REF TO cl_gui_custom_container.
DATA: i_tab TYPE truxs_t_text_data.
DATA: event_receiver TYPE REF TO lcl_event_receiver.
DATA: git_f4 TYPE lvc_t_f4,
gs_f4 TYPE lvc_s_f4.
DATA: row_id TYPE i.
DATA: it_return TYPE STANDARD TABLE OF ddshretval,
wa_return TYPE ddshretval.
DATA: it_exclude TYPE ui_functions.
DATA: flag TYPE i VALUE 1.
DATA: gv_error, c_subrc, t_subrc .
DATA: it_matnr TYPE STANDARD TABLE OF ty_matnr,
wa_matnr TYPE ty_matnr.
*----------------------------------------------------------------------*
* CLASS lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION .
PUBLIC SECTION.
METHODS handle_f4
FOR EVENT onf4
OF cl_gui_alv_grid
IMPORTING e_fieldname e_fieldvalue es_row_no
er_event_data et_bad_cells e_display.
ENDCLASS. "lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_f4.
*clear row_id.
row_id = es_row_no-row_id.
CASE e_fieldname.
WHEN 'MATNR'.
PERFORM f4_matnr.
WHEN 'VKORG'.
PERFORM f4_vkorg.
WHEN 'VTWEG'.
PERFORM f4_vtweg.
WHEN 'WERKS'.
PERFORM f4_werks.
WHEN 'DISMM'.
PERFORM f4_dismm.
WHEN 'BWSCL'.
PERFORM f4_bwscl.
WHEN 'MTVFP'.
PERFORM f4_mtvfp.
ENDCASE.
ENDMETHOD. "handle_f4
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
START-OF-SELECTION.
PERFORM call_screen.
*----------------------------------------------------------------------*
* MODULE STATUS_0100 OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'ZSTAUS'.
SET TITLEBAR 'ZTITLE'.
ENDMODULE. "STATUS_0100 OUTPUT
*----------------------------------------------------------------------*
* MODULE alv_0100 OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE alv_0100 OUTPUT.
* alv layout
PERFORM layout.
*free container and object
PERFORM free.
*alv grid display
PERFORM display.
ENDMODULE. " alv_0100 OUTPUT
*----------------------------------------------------------------------*
* MODULE USER_COMMAND_0100 INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
CLEAR sy-ucomm.
LEAVE TO SCREEN 0.
WHEN 'UPLOAD'.
CLEAR sy-ucomm.
PERFORM upload.
CALL METHOD c_alv->check_changed_data.
WHEN 'SAVE'.
CLEAR sy-ucomm.
CALL METHOD c_alv->check_changed_data.
PERFORM remove_blank_lines.
PERFORM duplicacy_check.
PERFORM validation.
* PERFORM test.
PERFORM update.
ENDCASE.
ENDMODULE. "USER_COMMAND_0100 INPUT

*&---------------------------------------------------------------------*
*& Form LAYOUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM layout.
wa_layout-edit = 'X'.
ENDFORM. "LAYOUT
*&---------------------------------------------------------------------*
*& Form FREE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM free.
IF c_alv IS NOT INITIAL.
CALL METHOD c_alv->free
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
FREE c_alv.
ENDIF.
ENDIF.
IF c_container IS NOT INITIAL.
CALL METHOD c_container->free
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
FREE c_container.
ENDIF.
ENDIF.
ENDFORM. "FREE
*&---------------------------------------------------------------------*
*& Form DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM display.
*Creating object of container.
CREATE OBJECT c_container
EXPORTING
container_name = 'CONTAINER'.
*Creating object of alv
CREATE OBJECT c_alv
EXPORTING
i_parent = c_container.
* Fieldcatalog.
PERFORM alv_fieldcat.
PERFORM exclude.
CLEAR wa_output.
IF flag = 1.
DO 20 TIMES.
APPEND wa_output TO it_output.
ENDDO.
CLEAR flag.
ENDIF.
CALL METHOD c_alv->set_table_for_first_display
EXPORTING
is_layout = wa_layout
it_toolbar_excluding = it_exclude
CHANGING
it_outtab = it_output
it_fieldcatalog = it_fieldcat.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_f4 FOR c_alv.
CLEAR: gs_f4, git_f4[].
gs_f4-fieldname = 'MATNR'. "Characteristics Profile
gs_f4-register = 'X'.
gs_f4-getbefore = 'X'.
INSERT gs_f4 INTO TABLE git_f4.
CLEAR: gs_f4.
gs_f4-fieldname = 'VKORG'. "Characteristics Profile
gs_f4-register = 'X'.
gs_f4-getbefore = 'X'.
INSERT gs_f4 INTO TABLE git_f4.
CLEAR: gs_f4.
gs_f4-fieldname = 'VTWEG'. "Characteristics Profile
gs_f4-register = 'X'.
gs_f4-getbefore = 'X'.
INSERT gs_f4 INTO TABLE git_f4.
CLEAR: gs_f4.
gs_f4-fieldname = 'WERKS'. "Characteristics Profile
gs_f4-register = 'X'.
gs_f4-getbefore = 'X'.
INSERT gs_f4 INTO TABLE git_f4.
CLEAR: gs_f4.
gs_f4-fieldname = 'DISMM'. "Characteristics Profile
gs_f4-register = 'X'.
gs_f4-getbefore = 'X'.
INSERT gs_f4 INTO TABLE git_f4.
* CLEAR: gs_f4.
* gs_f4-fieldname = 'PERKZ'. "Characteristics Profile
* gs_f4-register = 'X'.
* gs_f4-getbefore = 'X'.
* INSERT gs_f4 INTO TABLE git_f4.
CLEAR: gs_f4.
gs_f4-fieldname = 'BWSCL'. "Characteristics Profile
gs_f4-register = 'X'.
gs_f4-getbefore = 'X'.
INSERT gs_f4 INTO TABLE git_f4.
CLEAR: gs_f4.
gs_f4-fieldname = 'MTVFP'. "Characteristics Profile
gs_f4-register = 'X'.
gs_f4-getbefore = 'X'.
INSERT gs_f4 INTO TABLE git_f4.
CALL METHOD c_alv->register_f4_for_fields
EXPORTING
it_f4 = git_f4[].
ENDFORM. "DISPLAY
*&---------------------------------------------------------------------*
*& Form ALV_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM alv_fieldcat.
CLEAR wa_fieldcat.
REFRESH it_fieldcat.
wa_fieldcat-row_pos = 1.
wa_fieldcat-col_pos = 1.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-tabname = 'IT_OUTPUT'.
wa_fieldcat-coltext = 'Article No.'.
wa_fieldcat-f4availabl = 'X'.
wa_fieldcat-emphasize = 'X'.
wa_fieldcat-outputlen = 20.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-row_pos = 1.
wa_fieldcat-col_pos = 2.
wa_fieldcat-fieldname = 'VKORG'.
wa_fieldcat-tabname = 'IT_OUTPUT'.
wa_fieldcat-coltext = 'Sales Org.'.
wa_fieldcat-f4availabl = 'X'.
wa_fieldcat-outputlen = 8.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-row_pos = 1.
wa_fieldcat-col_pos = 3.
wa_fieldcat-fieldname = 'VTWEG'.
wa_fieldcat-tabname = 'IT_OUTPUT'.
wa_fieldcat-coltext = 'Dist Channel'.
wa_fieldcat-f4availabl = 'X'.
wa_fieldcat-outputlen = 8.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-row_pos = 1.
wa_fieldcat-col_pos = 4.
wa_fieldcat-fieldname = 'WERKS'.
wa_fieldcat-tabname = 'IT_OUTPUT'.
wa_fieldcat-coltext = 'Site'.
wa_fieldcat-f4availabl = 'X'.
wa_fieldcat-outputlen = 6.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-row_pos = 1.
wa_fieldcat-col_pos = 5.
wa_fieldcat-fieldname = 'DISMM'.
wa_fieldcat-tabname = 'IT_OUTPUT'.
wa_fieldcat-coltext = 'Rp Type'.
wa_fieldcat-f4availabl = 'X'.
wa_fieldcat-outputlen = 5.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-row_pos = 1.
wa_fieldcat-col_pos = 6.
wa_fieldcat-fieldname = 'SOBST'.
wa_fieldcat-tabname = 'IT_OUTPUT'.
wa_fieldcat-coltext = 'Target Stock'.
wa_fieldcat-outputlen = 10.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-row_pos = 1.
wa_fieldcat-col_pos = 7.
wa_fieldcat-fieldname = 'PRMOD'.
wa_fieldcat-tabname = 'IT_OUTPUT'.
wa_fieldcat-coltext = 'Forecast Model'.
* wa_fieldcat-DFIELDNAME = 'PRMOD'.
wa_fieldcat-ref_field = 'PRMOD'.
wa_fieldcat-ref_table = 'MPOP'.
wa_fieldcat-f4availabl = 'X'.
wa_fieldcat-outputlen = 10.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-row_pos = 1.
wa_fieldcat-col_pos = 8.
wa_fieldcat-fieldname = 'PERKZ'.
wa_fieldcat-tabname = 'IT_OUTPUT'.
wa_fieldcat-coltext = 'Period Indicator'.
wa_fieldcat-ref_field = 'PERKZ'.
wa_fieldcat-ref_table = 'MPOP'.
wa_fieldcat-f4availabl = 'X'.
wa_fieldcat-outputlen = 10.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-row_pos = 1.
wa_fieldcat-col_pos = 9.
wa_fieldcat-fieldname = 'BWSCL'.
wa_fieldcat-tabname = 'IT_OUTPUT'.
wa_fieldcat-coltext = 'Supply Source'.
wa_fieldcat-f4availabl = 'X'.
wa_fieldcat-outputlen = 10.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-row_pos = 1.
wa_fieldcat-col_pos = 10.
wa_fieldcat-fieldname = 'MTVFP'.
wa_fieldcat-tabname = 'IT_OUTPUT'.
wa_fieldcat-coltext = 'Availability Check'.
wa_fieldcat-f4availabl = 'X'.
wa_fieldcat-outputlen = 10.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " ALV_FIELDCAT
*&---------------------------------------------------------------------*
*& Form call_screen
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM call_screen .
CALL SCREEN 100.
ENDFORM. " call_screen
*&---------------------------------------------------------------------*
*& Form UPLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM upload .
DATA: p_file TYPE rlgrap-filename.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
program_name = sy-repid
dynpro_number = sy-dynnr
* FIELD_NAME = ' '
* STATIC = ' '
* MASK = ' '
CHANGING
file_name = p_file
* EXCEPTIONS
* MASK_TOO_LONG = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_line_header = 'X'
i_tab_raw_data = i_tab
i_filename = p_file
TABLES
i_tab_converted_data = it_output
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
PERFORM remove_blank_lines.
ENDFORM. " UPLOAD
*&---------------------------------------------------------------------*
*& Form save
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM update.
DATA: wa_headdata LIKE bapie1mathead.
DATA: bapi_return LIKE bapireturn1.
DATA: it_plantdata TYPE STANDARD TABLE OF bapie1marcrt,
wa_plantdata TYPE bapie1marcrt,
it_plantdatax TYPE STANDARD TABLE OF bapie1marcrtx,
wa_plantdatax TYPE bapie1marcrtx.
DATA: it_forecast TYPE STANDARD TABLE OF bapie1mpoprt,
wa_forecast TYPE bapie1mpoprt,
it_forecastx TYPE STANDARD TABLE OF bapie1mpoprtx,
wa_forecastx TYPE bapie1mpoprtx.
DATA: it_salesdata TYPE STANDARD TABLE OF bapie1mvkert,
wa_salesdata TYPE bapie1mvkert,
it_salesdatax TYPE STANDARD TABLE OF bapie1mvkertx,
wa_salesdatax TYPE bapie1mvkertx.
DATA: msg TYPE string.
DATA: it_msg TYPE esp1_message_tab_type,
wa_msg LIKE LINE OF it_msg.
DATA: lineno TYPE sy-tabix.
DATA: e_msg(50) TYPE c,
s_msg(50) TYPE c.
CLEAR it_msg[].
LOOP AT it_output INTO wa_output.
CLEAR lineno.
lineno = sy-tabix.
CLEAR: wa_headdata, wa_plantdata, wa_plantdatax,
wa_forecast, wa_forecastx, wa_salesdata,
wa_salesdatax.
REFRESH: it_plantdata,it_plantdatax,it_forecast,
it_forecastx,it_salesdata,it_salesdatax.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_output-matnr
IMPORTING
output = wa_output-matnr.
wa_headdata-material = wa_output-matnr.
wa_headdata-logst_view = 'X'.
wa_plantdata-material = wa_output-matnr.
wa_plantdata-plant = wa_output-werks.
IF wa_output-dismm IS NOT INITIAL.
wa_plantdata-mrp_type = wa_output-dismm.
ENDIF.
IF wa_output-sobst IS NOT INITIAL.
wa_plantdata-target_stock = wa_output-sobst.
ENDIF.
IF wa_output-perkz IS NOT INITIAL.
wa_plantdata-period_ind = wa_output-perkz.
ENDIF.
IF wa_output-bwscl IS NOT INITIAL.
wa_plantdata-sup_source = wa_output-bwscl.
ENDIF.
IF wa_output-mtvfp IS NOT INITIAL.
wa_plantdata-availcheck = wa_output-mtvfp.
ENDIF.
APPEND wa_plantdata TO it_plantdata.
wa_plantdatax-material = wa_output-matnr.
wa_plantdatax-plant = wa_output-werks.
IF wa_output-dismm IS NOT INITIAL.
wa_plantdatax-mrp_type = 'X'.
ENDIF.
IF wa_output-sobst IS NOT INITIAL.
wa_plantdatax-target_stock = 'X'.
ENDIF.
IF wa_output-perkz IS NOT INITIAL.
wa_plantdatax-period_ind = 'X'.
ENDIF.
IF wa_output-bwscl IS NOT INITIAL.
wa_plantdatax-sup_source = 'X'.
ENDIF.
IF wa_output-mtvfp IS NOT INITIAL.
wa_plantdatax-availcheck = 'X'.
ENDIF.
APPEND wa_plantdatax TO it_plantdatax.
IF wa_output-prmod IS NOT INITIAL.
wa_forecast-material = wa_output-matnr.
wa_forecast-plant = wa_output-werks..
wa_forecast-fore_model = wa_output-prmod.
APPEND wa_forecast TO it_forecast.
wa_forecastx-material = wa_output-matnr.
wa_forecastx-plant = wa_output-werks.
wa_forecastx-fore_model = 'X'.
APPEND wa_forecastx TO it_forecastx.
ENDIF.
wa_salesdata-material = wa_output-matnr.
wa_salesdata-sales_org = wa_output-vkorg.
wa_salesdata-distr_chan = wa_output-vtweg.
APPEND wa_salesdata TO it_salesdata.
wa_salesdatax-material = wa_output-matnr.
wa_salesdatax-sales_org = wa_output-vkorg.
wa_salesdatax-distr_chan = wa_output-vtweg.
APPEND wa_salesdatax TO it_salesdatax.

CALL FUNCTION 'BAPI_MATERIAL_MAINTAINDATA_RT'


EXPORTING
headdata = wa_headdata
IMPORTING
return = bapi_return
TABLES
plantdata = it_plantdata
plantdatax = it_plantdatax
forecastparameters = it_forecast
forecastparametersx = it_forecastx
salesdata = it_salesdata
salesdatax = it_salesdatax.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'


EXPORTING
wait = 'X'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = wa_output-matnr
IMPORTING
output = wa_output-matnr.
CONCATENATE 'Article no' wa_output-matnr 'not updated'
INTO e_msg SEPARATED BY space.
CONCATENATE 'Article no' wa_output-matnr 'updated'
INTO s_msg SEPARATED BY space.
IF bapi_return-type = 'E'.
wa_msg-msgty = 'E'.
wa_msg-msgid = 'ZMM'.
wa_msg-msgno = '011'.
wa_msg-lineno = lineno.
wa_msg-msgv1 = e_msg.
APPEND wa_msg TO it_msg.
CLEAR wa_msg.
ELSEIF bapi_return-type = 'S'.
wa_msg-msgty = 'S'.
wa_msg-msgid = 'ZMM'.
wa_msg-msgno = '011'.
wa_msg-lineno = lineno.
wa_msg-msgv1 = s_msg.
APPEND wa_msg TO it_msg.
ENDIF.
ENDLOOP.
CALL FUNCTION 'C14Z_MESSAGES_SHOW_AS_POPUP'
TABLES
i_message_tab = it_msg.
CLEAR wa_output.

ENDFORM. " save


*&---------------------------------------------------------------------*
*& Form F4_MATNR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f4_matnr .
CLEAR it_matnr[].
SELECT matnr
FROM mara
INTO TABLE it_matnr
WHERE attyp = '00'
OR attyp = '02'.
SORT it_matnr.
DELETE ADJACENT DUPLICATES FROM it_matnr COMPARING ALL FIELDS.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'MATNR'
dynpprog = sy-repid
dynpnr = sy-dynnr
window_title = 'Material No'
value_org = 'S'
TABLES
value_tab = it_matnr[]
return_tab = it_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE it_return INTO wa_return INDEX 1.
IF sy-subrc = 0.
wa_output-matnr = wa_return-fieldval.
ENDIF.
IF wa_output-matnr IS NOT INITIAL.
MODIFY it_output FROM wa_output INDEX row_id
TRANSPORTING matnr.
ENDIF.
CALL METHOD c_alv->refresh_table_display.
CLEAR: wa_return,it_return[],wa_output.
ENDFORM. " F4_MATNR
*&---------------------------------------------------------------------*
*& Form f4_vkorg
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f4_vkorg .
TYPES: BEGIN OF ty_vkorg,
vkorg TYPE vkorg,
END OF ty_vkorg.
DATA: it_vkorg TYPE STANDARD TABLE OF ty_vkorg,
wa_vkorg TYPE ty_vkorg.
READ TABLE it_output INTO wa_output INDEX row_id.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_output-matnr
IMPORTING
output = wa_output-matnr.
CLEAR it_matnr[].
SELECT matnr
FROM mara
INTO TABLE it_matnr
WHERE matnr = wa_output-matnr
AND ( attyp = '00' OR attyp = '02').
IF wa_output-matnr IS NOT INITIAL AND sy-subrc IS INITIAL.
SELECT vkorg
FROM mvke
INTO TABLE it_vkorg
WHERE matnr = wa_output-matnr.
IF sy-subrc <> 0.
MESSAGE i000(su) WITH 'No sales organisation for'
wa_output-matnr 'article'.
ENDIF.
ELSE.
MESSAGE i000(su) WITH 'Invalid Material no'.
ENDIF.
SORT it_vkorg.
DELETE ADJACENT DUPLICATES FROM it_vkorg COMPARING ALL FIELDS.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'VKORG'
dynpprog = sy-repid
dynpnr = sy-dynnr
window_title = 'Sales Org'
value_org = 'S'
TABLES
value_tab = it_vkorg[]
return_tab = it_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE it_return INTO wa_return INDEX 1.
IF sy-subrc = 0.
wa_output-vkorg = wa_return-fieldval.
ENDIF.
IF wa_output-vkorg IS NOT INITIAL.
MODIFY it_output FROM wa_output INDEX row_id
TRANSPORTING vkorg.
ENDIF.
CALL METHOD c_alv->refresh_table_display.
CLEAR: wa_return,it_return[],wa_output.
ENDFORM. " f4_vkorg
*&---------------------------------------------------------------------*
*& Form f4_vtweg
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f4_vtweg .
TYPES: BEGIN OF ty_vtweg,
vtweg TYPE vtweg,
END OF ty_vtweg.
DATA: it_vtweg TYPE STANDARD TABLE OF ty_vtweg,
wa_vtweg TYPE ty_vtweg.
READ TABLE it_output INTO wa_output INDEX row_id.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_output-matnr
IMPORTING
output = wa_output-matnr.
IF wa_output-matnr IS NOT INITIAL.
IF wa_output-vkorg IS NOT INITIAL.
SELECT vtweg
FROM mvke
INTO TABLE it_vtweg
WHERE vkorg = wa_output-vkorg
AND matnr = wa_output-matnr.
IF sy-subrc <> 0.
MESSAGE i000(su) WITH 'No distribution channel for article'
wa_output-matnr 'in sales org.' wa_output-vkorg .
ENDIF.
ELSE.
MESSAGE i000(su) WITH ' Sales organisation doesnot exist'.
ENDIF.
ELSE.
MESSAGE i000(su) WITH ' Article doesnot exist'.
ENDIF.
SORT it_vtweg.
DELETE ADJACENT DUPLICATES FROM it_vtweg COMPARING ALL FIELDS.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'VTWEG'
dynpprog = sy-repid
dynpnr = sy-dynnr
window_title = 'Distribution channel'
value_org = 'S'
TABLES
value_tab = it_vtweg[]
return_tab = it_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE it_return INTO wa_return INDEX 1.
IF sy-subrc = 0.
wa_output-vtweg = wa_return-fieldval.
ENDIF.
IF wa_output-vtweg IS NOT INITIAL.
MODIFY it_output FROM wa_output INDEX row_id
TRANSPORTING vtweg.
ENDIF.
CALL METHOD c_alv->refresh_table_display.
CLEAR: wa_return,it_return[],wa_output.
ENDFORM. " f4_vtweg
*&---------------------------------------------------------------------*
*& Form f4_dismm
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f4_dismm .
TYPES: BEGIN OF ty_dismm,
dismm TYPE dismm,
dibez TYPE dibez,
END OF ty_dismm.
DATA: it_dismm TYPE STANDARD TABLE OF ty_dismm,
wa_dismm TYPE ty_dismm.
SELECT t438a~dismm
t438t~dibez
INTO CORRESPONDING FIELDS OF TABLE it_dismm
FROM t438a INNER JOIN t438t ON t438a~dismm = t438t~dismm
AND t438t~spras = 'E'.
SORT it_dismm.
DELETE ADJACENT DUPLICATES FROM it_dismm COMPARING ALL FIELDS.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'DISMM'
dynpprog = sy-repid
dynpnr = sy-dynnr
window_title = 'RP type '
value_org = 'S'
TABLES
value_tab = it_dismm[]
return_tab = it_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE it_return INTO wa_return INDEX 1.
IF sy-subrc = 0.
wa_output-dismm = wa_return-fieldval.
ENDIF.
IF wa_output-dismm IS NOT INITIAL.
MODIFY it_output FROM wa_output INDEX row_id
TRANSPORTING dismm.
ENDIF.
CALL METHOD c_alv->refresh_table_display.
CLEAR: wa_return,it_return[],wa_output.
ENDFORM. " f4_dismm
*&---------------------------------------------------------------------*
*& Form f4_prmod
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f4_werks .
TYPES: BEGIN OF ty_werks,
werks TYPE werks_d,
END OF ty_werks.
DATA: it_werks TYPE STANDARD TABLE OF ty_werks,
wa_werks TYPE ty_werks.
READ TABLE it_output INTO wa_output INDEX row_id.
IF wa_output-matnr IS NOT INITIAL.
IF wa_output-vkorg IS NOT INITIAL.
IF wa_output-vtweg IS NOT INITIAL.
SELECT werks
FROM t001w
INTO TABLE it_werks
WHERE vkorg = wa_output-vkorg
AND vtweg = wa_output-vtweg.
IF sy-subrc <> 0.
MESSAGE i000(su) WITH 'No site for sales organisation' wa_output-vkorg
'and distribution channel' wa_output-vtweg.
ENDIF.
ELSE.
MESSAGE i000(su) WITH 'Distribution channel doesnot exist'.
ENDIF.
ELSE.
MESSAGE i000(su) WITH 'Sales organisation doesnot exist'.
ENDIF.
ELSE.
MESSAGE i000(su) WITH 'Article doesnot exist'.
ENDIF.
SORT it_werks.
DELETE ADJACENT DUPLICATES FROM it_werks COMPARING ALL FIELDS.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'


EXPORTING
retfield = 'WERKS'
dynpprog = sy-repid
dynpnr = sy-dynnr
window_title = 'Site'
value_org = 'S'
TABLES
value_tab = it_werks[]
return_tab = it_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE it_return INTO wa_return INDEX 1.
IF sy-subrc = 0.
wa_output-werks = wa_return-fieldval.
ENDIF.
IF wa_output-werks IS NOT INITIAL.
MODIFY it_output FROM wa_output INDEX row_id
TRANSPORTING werks.
ENDIF.
CALL METHOD c_alv->refresh_table_display.
CLEAR: wa_return,it_return[],wa_output.
ENDFORM. " f4_werks
*---------------------------------------------------------------------*
*& Form f4_bwscl
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f4_bwscl .
TYPES: BEGIN OF bwscl,
bwscl TYPE bwscl,
bwscb TYPE bqscb,
END OF bwscl.
DATA: it_bwscl TYPE STANDARD TABLE OF bwscl,
wa_bwscl TYPE bwscl.
SELECT tmbw1~bwscl
tmbwt~bwscb
INTO CORRESPONDING FIELDS OF TABLE it_bwscl
FROM tmbw1 INNER JOIN tmbwt ON tmbw1~bwscl = tmbwt~bwscl
AND spras = 'E'.
SORT it_bwscl.
DELETE ADJACENT DUPLICATES FROM it_bwscl COMPARING ALL FIELDS.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'BWSCL'
dynpprog = sy-repid
dynpnr = sy-dynnr
window_title = 'Supply Source'
value_org = 'S'
TABLES
value_tab = it_bwscl[]
return_tab = it_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE it_return INTO wa_return INDEX 1.
IF sy-subrc = 0.
wa_output-bwscl = wa_return-fieldval.
ENDIF.
IF wa_output-bwscl IS NOT INITIAL.
MODIFY it_output FROM wa_output INDEX row_id
TRANSPORTING bwscl.
ENDIF.
CALL METHOD c_alv->refresh_table_display.
CLEAR: wa_return,it_return[],wa_output.
ENDFORM. " f4_bwscl
*&---------------------------------------------------------------------*
*& Form f4_mtvfp
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f4_mtvfp .
TYPES: BEGIN OF mtvfp,
mtvfp TYPE tmvft-mtvfp,
bezei TYPE bezei20,
END OF mtvfp.
DATA: it_mtvfp TYPE STANDARD TABLE OF mtvfp,
wa_mtvfp TYPE mtvfp.
SELECT tmvf~mtvfp
tmvft~bezei
INTO CORRESPONDING FIELDS OF TABLE it_mtvfp
FROM tmvf INNER JOIN tmvft ON tmvf~mtvfp = tmvft~mtvfp
AND spras = 'E'.
SORT it_mtvfp.
DELETE ADJACENT DUPLICATES FROM it_mtvfp COMPARING ALL FIELDS.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'MTVFP'
dynpprog = sy-repid
dynpnr = sy-dynnr
window_title = 'availability Check'
value_org = 'S'
TABLES
value_tab = it_mtvfp[]
return_tab = it_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
READ TABLE it_return INTO wa_return INDEX 1.
IF sy-subrc = 0.
wa_output-mtvfp = wa_return-fieldval.
ENDIF.
IF wa_output-mtvfp IS NOT INITIAL.
MODIFY it_output FROM wa_output INDEX row_id
TRANSPORTING mtvfp.
ENDIF.
CALL METHOD c_alv->refresh_table_display.
CLEAR: wa_return,it_return[],wa_output.
ENDFORM. " f4_mtvfp
*&---------------------------------------------------------------------*
*& Form exclude
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM exclude .
CLEAR: it_exclude.
INSERT cl_gui_alv_grid=>mc_fc_loc_undo INTO TABLE it_exclude. "Un
do
INSERT cl_gui_alv_grid=>mc_fc_loc_append_row INTO TABLE it_exclude. "Ap
pend Row
INSERT cl_gui_alv_grid=>mc_fc_loc_copy INTO TABLE it_exclude. "Co
py
INSERT cl_gui_alv_grid=>mc_fc_loc_copy_row INTO TABLE it_exclude. "Co
py Row
INSERT cl_gui_alv_grid=>mc_fc_loc_cut INTO TABLE it_exclude. "Cu
t
* INSERT cl_gui_alv_grid=>mc_fc_loc_delete_row INTO TABLE git_exclude_0108.
"Delete Row
* INSERT cl_gui_alv_grid=>mc_fc_loc_insert_row INTO TABLE git_exclude_0108.
"Insert Row
INSERT cl_gui_alv_grid=>mc_fc_loc_paste INTO TABLE it_exclude. "Pa
ste Row
INSERT cl_gui_alv_grid=>mc_fc_info INTO TABLE it_exclude. "In
formation
INSERT cl_gui_alv_grid=>mc_fc_refresh INTO TABLE it_exclude. "Re
fresh ALV
INSERT cl_gui_alv_grid=>mc_fc_loc_paste_new_row INTO TABLE it_exclude. "Pa
ste New Row
INSERT cl_gui_alv_grid=>mc_fc_graph INTO TABLE it_exclude.
ENDFORM. " exclude
*&---------------------------------------------------------------------*
*& Form remove_blank_lines
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM remove_blank_lines .
CALL METHOD c_alv->check_changed_data.
DELETE it_output WHERE matnr IS INITIAL
AND vkorg IS INITIAL
AND vtweg IS INITIAL
AND werks IS INITIAL
AND dismm IS INITIAL
AND sobst IS INITIAL
AND prmod IS INITIAL
AND perkz IS INITIAL
AND bwscl IS INITIAL
AND mtvfp IS INITIAL.
ENDFORM. " remove_blank_lines
*&---------------------------------------------------------------------*
*& Form flush_error_handler
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_SY_SUBRC text
*----------------------------------------------------------------------*
" flush_error_handler
*&---------------------------------------------------------------------*
*& Form VALIDATION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM validation .
DATA: lv_tabix TYPE n LENGTH 3.
CLEAR lv_tabix.
* SORT it_output ASCENDING BY matnr.
LOOP AT it_output INTO wa_output.
lv_tabix = sy-tabix.
IF wa_output-matnr IS INITIAL.
PERFORM crt_mandt_msg USING 'Article Number' lv_tabix.
ENDIF.
IF wa_output-vkorg IS INITIAL.
PERFORM crt_mandt_msg USING 'Sales organization' lv_tabix.
ENDIF.
IF wa_output-vtweg IS INITIAL.
PERFORM crt_mandt_msg USING 'Distribution channel' lv_tabix.
ENDIF.
IF wa_output-werks IS INITIAL.
PERFORM crt_mandt_msg USING 'Site' lv_tabix.
ENDIF.
IF wa_output-matnr IS NOT INITIAL.
PERFORM matnr_validation USING 'Article Number' lv_tabix.
ENDIF.
IF wa_output-vkorg IS NOT INITIAL.
PERFORM vkorg_validation USING 'Sales Organization' lv_tabix.
ENDIF.
IF wa_output-vtweg IS NOT INITIAL.
PERFORM vkorg_vtweg_validation USING lv_tabix.
ENDIF.
IF wa_output-werks IS NOT INITIAL.
PERFORM werks_validation USING lv_tabix.
ENDIF.
ENDLOOP.
ENDFORM. " VALIDATION
*&---------------------------------------------------------------------*
*& Form crt_mandt_msg
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_2412 text
* -->P_LV_TABIX text
*----------------------------------------------------------------------*
FORM crt_mandt_msg USING i_msg1 TYPE string
i_tabix TYPE n .
DATA: lv_line1 TYPE string, "Message Line-1
lv_line2 TYPE string. "Message Line-2
gv_error = 'X'.
c_subrc = 'X'.
IF c_subrc EQ 'X'.
t_subrc = 'X'.
ENDIF.
CONCATENATE 'Line No.: ' i_tabix
INTO lv_line1 SEPARATED BY space.
CONCATENATE i_msg1 'cannot be left blank.'
INTO lv_line2 SEPARATED BY space.
MESSAGE e000(su) WITH lv_line1 lv_line2 .
ENDFORM. " crt_mandt_msg
*&---------------------------------------------------------------------*
*& Form matnr_validation
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_2474 text
* -->P_LV_TABIX text
*----------------------------------------------------------------------*
FORM matnr_validation USING i_msg1 TYPE string
i_tabix TYPE n .
DATA: lv_line1 TYPE string, "Message Line-1
lv_line2 TYPE string. "Message Line-2
DATA: lv_matnr TYPE mara-matnr.
CLEAR lv_matnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_output-matnr
IMPORTING
output = wa_output-matnr.
SELECT SINGLE matnr
FROM mara
INTO lv_matnr
WHERE matnr = wa_output-matnr
AND ( attyp = '00'
OR attyp = '02' ).
IF sy-subrc <> 0.
gv_error = 'X'.
c_subrc = 'X'.
IF c_subrc EQ 'X'.
t_subrc = 'X'.
ENDIF.
CONCATENATE 'Line No.: ' i_tabix
INTO lv_line1 SEPARATED BY space.
CONCATENATE i_msg1 'is invalid, use f4 for help'
INTO lv_line2 SEPARATED BY space.
MESSAGE e000(su) WITH lv_line1 lv_line2 .
EXIT.
ENDIF.
ENDFORM. " matnr_validation
*&---------------------------------------------------------------------*
*& Form vkorg_validation
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_2485 text
* -->P_LV_TABIX text
*----------------------------------------------------------------------*
FORM vkorg_validation USING i_msg1 TYPE string
i_tabix TYPE n.
DATA: lv_line1 TYPE string, "Message Line-1
lv_line2 TYPE string. "Message Line-2
DATA: lv_vkorg TYPE tvkov-vkorg.
CLEAR gv_error.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_output-matnr
IMPORTING
output = wa_output-matnr.
SELECT SINGLE vkorg
FROM mvke
INTO lv_vkorg
WHERE vkorg EQ wa_output-vkorg
AND matnr EQ wa_output-matnr.
IF sy-subrc IS NOT INITIAL.
gv_error = 'X'.
c_subrc = 'X'.
IF c_subrc EQ 'X'.
t_subrc = 'X'.
ENDIF.
CONCATENATE 'Line No.: ' i_tabix
INTO lv_line1 SEPARATED BY space.
CONCATENATE i_msg1 'is invalid, use F4 for Help.'
INTO lv_line2 SEPARATED BY space.
MESSAGE e000(su) WITH lv_line1 lv_line2 .
EXIT.
ENDIF.

ENDFORM. " vkorg_validation


*&---------------------------------------------------------------------*
*& Form vkorg_vtweg_validation
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LV_TABIX text
*----------------------------------------------------------------------*
FORM vkorg_vtweg_validation USING i_tabix TYPE n.
DATA: lv_line1 TYPE string, "Message Line-1
lv_line2 TYPE string. "Message Line-2
DATA: lv_vtweg TYPE tvkov-vtweg.
CLEAR gv_error.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_output-matnr
IMPORTING
output = wa_output-matnr.
SELECT SINGLE vtweg
FROM mvke
INTO lv_vtweg
WHERE vtweg EQ wa_output-vtweg
AND vkorg EQ wa_output-vkorg
AND matnr EQ wa_output-matnr.
IF sy-subrc IS NOT INITIAL.
gv_error = 'X'.
c_subrc = 'X'.
IF c_subrc EQ 'X'.
t_subrc = 'X'.
ENDIF.
CONCATENATE 'Line No.: ' i_tabix
INTO lv_line1 SEPARATED BY space.
lv_line2 = ' Distribution Channel is invalid Use F4 for Help'.
MESSAGE e000(su) WITH lv_line1 lv_line2 .
EXIT.
ENDIF.
ENDFORM. " vkorg_vtweg_validation
*&---------------------------------------------------------------------*
*& Form werks_validation
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_2506 text
* -->P_LV_TABIX text
*----------------------------------------------------------------------*
FORM werks_validation USING i_tabix TYPE n.
DATA: lv_line1 TYPE string, "Message Line-1
lv_line2 TYPE string. "Message Line-2
DATA: lv_werks TYPE t001w-werks.
CLEAR gv_error.
SELECT SINGLE werks
FROM t001w
INTO lv_werks
WHERE vkorg = wa_output-vkorg
AND vtweg = wa_output-vtweg.
IF sy-subrc <> 0.

gv_error = 'X'.
c_subrc = 'X'.
IF c_subrc EQ 'X'.
t_subrc = 'X'.
ENDIF.
CONCATENATE 'Line No.: ' i_tabix
INTO lv_line1 SEPARATED BY space.
lv_line2 = ' Site is invalid Use F4 for Help'.
MESSAGE e000(su) WITH lv_line1 lv_line2 .
EXIT.
ENDIF.
ENDFORM. " werks_validation
*&---------------------------------------------------------------------*
*& Form duplicacy_check
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM duplicacy_check .
DATA: index TYPE sy-index,
index1 TYPE sy-index.
DATA: count TYPE i.
DESCRIBE TABLE it_output LINES count.
IF count IS INITIAL.
MESSAGE e000(su) WITH 'Enter article first'.
ENDIF.
WHILE index1 <= count.
index = sy-index .
index1 = sy-index + 1.
READ TABLE it_output INTO wa_output INDEX index.
IF wa_output-matnr IS NOT INITIAL and count > 1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_output-matnr
IMPORTING
output = wa_output-matnr.
READ TABLE it_output INTO wa_output1 INDEX index1.
IF wa_output1-matnr IS NOT INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_output1-matnr
IMPORTING
output = wa_output1-matnr.
IF wa_output-matnr = wa_output1-matnr.
MESSAGE e000(su) WITH 'article no' wa_output1-matnr 'repeated'.
ENDIF.
CLEAR: wa_output,wa_output1.
ENDIF.
ENDIF.
ENDWHILE.
ENDFORM. " duplicacy_check
*&---------------------------------------------------------------------*
*& Form test
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
*FORM test .
* DATA: BEGIN OF it_upd OCCURS 0,
* tabname(30) TYPE c,
* fieldname(30) TYPE c,
* END OF it_upd.
* DATA: BRET TYPE STANDARD TABLE OF BAPIRET2.
* DATA: wa_upd LIKE LINE OF it_upd.
* DATA: it_wrpl TYPE STANDARD TABLE OF wrpl,
* wa_wrpl TYPE wrpl.
*
* wa_upd-tabname = 'WRPL'.
* wa_UPD-fieldname = 'SOBST'.
* APPEND wa_upd TO it_upd.
* LOOP AT IT_OUTPUT INTO WA_OUTPUT.
*
* WA_WRPL-SOBST = WA_OUTPUT-SOBST.
*APPEND WA_WRPL TO IT_WRPL.
* CALL FUNCTION 'MATERIAL_UPDATE_LOGISTIC_DATA'
* TABLES
* it_upd_field_names = it_upd
** IT_NEW_MARC_DATA =
* it_new_wrpl_data = IT_WRPL
** IT_NEW_MPOP_DATA =
** IT_SITE_KEYS =
* ot_messages = BRET.
** OT_PROCESSED_MARC_DATA =
** OT_PROCESSED_WRPL_DATA =
** OT_PROCESSED_MPOP_DATA =
** EXCEPTIONS
** WRONG_INPUT_DATA = 1
** WRONG_REFERENCE_HANDLING = 2
** LOCK_PROBLEMS = 3
** FOREIGN_KEY_CHECK_ERROR = 4
** SPECIAL_CHECK_ERROR = 5
** OTHERS = 6
* .
* IF sy-subrc <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* ENDIF.
* ENDLOOP.
*ENDFORM. " test

You might also like