一:根据对方给的wsdl 的接口地址创建Web 的逻辑端口
1:例如这个用C#写的Web
2.我们需要在SAP里建立一个Service Consumers 的服务记得后缀要加?wsdl
2:然后就会生成对应方法的出参 入参 返回的消息根据接口方法来判断
二:如何通过LPCONFIG建立逻辑端口或者通过SOAMANAGER来建立
1:指定对应的名称
2:绑定对应的地址再绑定对应SOAP的操作
SOAP操作 = ”Namespace && 调用方法“
三:程序里改如何调用呢
*&---------------------------------------------------------------------*
*& REPORT ZMM_COUNT_MATNR
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zmm_count_matnr.
DATA:lr_alv_data TYPE REF TO data.
FIELD-SYMBOLS : <lt_alv_data> TYPE ANY TABLE .
FIELD-SYMBOLS : <ls_data> TYPE any.
DATA:zwb_log_s TYPE zwb_log.
DATA:zwb_log_t TYPE TABLE OF zwb_log.
DATA:zwb_log_id TYPE TABLE OF zwb_log.
DATA:zwb_log_del TYPE TABLE OF zwb_log.
DATA:zwb_log_in TYPE TABLE OF zwb_log.
DATA:lt_lgort TYPE TABLE OF zwb_lgort.
DATA:lv_x.
DATA:BEGIN OF gs_excel,
werks TYPE string,
lgort TYPE string,
matnr TYPE string,
charg TYPE string,
labst TYPE string,
fact TYPE string,
extime TYPE char08,
type TYPE string,
message TYPE string,
datum TYPE string,
END OF gs_excel.
DATA:zwb_log_excel LIKE TABLE OF gs_excel.
DATA gt_fieldcat TYPE lvc_t_fcat. "列结构
DATA gs_fieldcat TYPE lvc_s_fcat. "列结构 --工作区
DATA gs_layout TYPE lvc_s_layo. "表单格式
TYPES: BEGIN OF ty_fieldname,
name TYPE char20,
END OF ty_fieldname.
DATA: lt_fieldname TYPE TABLE OF ty_fieldname WITH HEADER LINE.
DATA:lv_data1 TYPE sy-datum.
DATA:lv_data2 TYPE sy-datum.
IF sy-datum+7(1) = 1.
lv_data1 = sy-datum.
lv_data2 = sy-datum - 1.
ELSE.
lv_data1 = sy-datum.
lv_data2 = sy-datum.
ENDIF.
DEFINE fieldcatset.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = &1. "字段名称
gs_fieldcat-coltext = &2. "字段显示名称
gs_fieldcat-outputlen = &3. "输出长度
APPEND gs_fieldcat TO gt_fieldcat.
END-OF-DEFINITION.
PARAMETERS:s_werks1 TYPE marc-werks OBLIGATORY.
RANGES:s_werks FOR marc-werks.
RANGES:s_matnr FOR mara-matnr.
RANGES:s_lgort FOR mard-lgort.
DATA: lcx_ex TYPE REF TO cx_ai_system_fault.
DATA: lv_err_msg TYPE string,
lcx_fault TYPE REF TO cx_ai_application_fault,
lcl_zmm20 TYPE REF TO zmm20co_if_trs_cpi_delivery_so,
ls_acc_input TYPE zmm20get_pdmaterial_data_soap1,
ls_acc_output TYPE zmm20get_pdmaterial_data_soap,
ls_return TYPE zmm20pdmaterial_return_item.
DATA:zmm20pdmaterial_result_item TYPE zmm20pdmaterial_result_item.
AT SELECTION-SCREEN OUTPUT.
IF sy-datum+6(2) = '01' .
MESSAGE '还未到盘点时间' TYPE 'E'.
ENDIF.
END-OF-SELECTION.
PERFORM get_data. "获取数据
PERFORM check_data. "检查数据
PERFORM frm_pre_fieldcat. "设置字段
PERFORM frm_set_layout. "设置布局
PERFORM frm_show_alv.
*PERFORM Filter_data. "过滤发送的数据
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM get_data .
s_werks+0(3) = 'IEQ'.
s_werks-low = s_werks1.
APPEND s_werks.
SELECT * FROM zwb_lgort WHERE werks IN @s_werks INTO CORRESPONDING FIELDS OF TABLE @lt_lgort.
LOOP AT lt_lgort INTO DATA(ls_lgort).
SELECT single lgort FROM ZMM_LGORT
WHERE werks = @ls_lgort-werks
AND lgort = @ls_lgort-lgort
INTO @DATA(ls_mm_lgort) .
IF ls_mm_lgort IS INITIAL.
MESSAGE '盘点的线边仓' && ls_lgort-lgort && '不存在!!' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE PROGRAM.
ENDIF.
ENDLOOP.
CLEAR:s_lgort.
LOOP AT lt_lgort INTO ls_lgort.
s_lgort+0(3) = 'IEQ'.
s_lgort-low = ls_lgort-lgort.
APPEND s_lgort.
ENDLOOP.
cl_salv_bs_runtime_info=>set( EXPORTING display = abap_false
metadata = abap_false
data = abap_true ).
CLEAR lr_alv_data.
UNASSIGN <lt_alv_data>.
SUBMIT rm07mlbs WITH werks IN s_werks
WITH matnr IN s_matnr
WITH lgort IN s_lgort
WITH pa_sond = ''
WITH nozero = 'X'
WITH xmchb = 'X'
WITH pa_hsq = ''
WITH pa_flt = 'X'
AND RETURN.
TRY.
cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = lr_alv_data ).
ASSIGN lr_alv_data->* TO <lt_alv_data>.
CATCH cx_salv_bs_sc_runtime_info.
MESSAGE 'Unable to retrieve ALV data! Please try other conditions.' TYPE 'E'.
ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ).
ENDFORM.
*&---------------------------------------------------------------------*
*& Form check_data
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM check_data .
DATA:lv_posnr TYPE n LENGTH 6.
DATA:lv_uuid TYPE uuid.
CLEAR:lv_uuid.
TRY.
CALL METHOD cl_system_uuid=>if_system_uuid_static~create_uuid_x16
RECEIVING
uuid = lv_uuid.
CATCH cx_uuid_error.
ENDTRY.
IF <lt_alv_data> IS ASSIGNED.
UNASSIGN <ls_data>.
LOOP AT <lt_alv_data> ASSIGNING <ls_data>."即所需要内表数据
MOVE-CORRESPONDING <ls_data> TO zwb_log_s.
zwb_log_s-uuid = lv_uuid.
READ TABLE lt_lgort INTO DATA(ls_lgort) WITH KEY werks = zwb_log_s-werks
lgort = zwb_log_s-lgort.
IF sy-subrc = 0.
zwb_log_s-fact = ls_lgort-fact.
ENDIF.
IF zwb_log_s-matnr+0(6) <> 'Q01-EN' AND zwb_log_s-labst = '0'.
CLEAR:zwb_log_s.
ENDIF.
IF zwb_log_s-matnr IS NOT INITIAL.
SELECT SINGLE vfdat FROM mch1 WHERE matnr = @zwb_log_s-matnr AND charg = @zwb_log_s-charg INTO @DATA(ls_vfadt).
"没有过期日期赋值
IF ls_vfadt IS INITIAL.
zwb_log_s-extime = sy-datum+0(7) && '2000000'.
ELSE.
zwb_log_s-extime = ls_vfadt && '000000'.
ENDIF.
IF zwb_log_s-extime >= sy-datum && '000000'.
* IF zwb_log_s-extime >= '20240901000000'.
zwb_log_s-type = ''.
zwb_log_s-message = ''.
zwb_log_s-datum = ''.
zwb_log_s-uzeit = ''.
ELSE.
zwb_log_s-type = 'D'.
zwb_log_s-message = 'SAP货架过期日期已过期'.
zwb_log_s-datum = sy-datum.
zwb_log_s-uzeit = sy-uzeit.
ENDIF.
lv_posnr = lv_posnr + 1.
zwb_log_s-posnr = lv_posnr.
APPEND zwb_log_s TO zwb_log_t.
ENDIF.
ENDLOOP.
ENDIF.
"先检索相同批次不同物料的
MOVE-CORRESPONDING zwb_log_t TO zwb_log_id.
DATA(lv_lines1) = lines( zwb_log_t ).
SORT zwb_log_id BY charg.
DELETE ADJACENT DUPLICATES FROM zwb_log_id COMPARING charg.
DATA(lv_lines2) = lines( zwb_log_id ).
IF lv_lines1 <> lv_lines2.
CALL FUNCTION 'CTVB_COMPARE_TABLES'
EXPORTING
table_old = zwb_log_t
table_new = zwb_log_id
key_length = 100 "键长度,指定内表中的前若干个字节为主键,做为内表行是否为增加的判断条件。
IMPORTING
table_del = zwb_log_del. "new比old 少的数据
LOOP AT zwb_log_del INTO DATA(zwb_log_des).
LOOP AT zwb_log_t INTO zwb_log_s WHERE charg = zwb_log_des-charg.
zwb_log_s-type = 'D'.
zwb_log_s-message = '批次相同不同料号'.
zwb_log_s-datum = sy-datum.
zwb_log_s-uzeit = sy-uzeit.
MODIFY zwb_log_t FROM zwb_log_s.
ENDLOOP.
ENDLOOP.
ENDIF.
SORT zwb_log_t BY werks lgort matnr.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_pre_fieldcat
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_pre_fieldcat .
fieldcatset:
'WERKS' '工厂' '80' ,
'LGORT' '储存地点' '80' ,
'MATNR' '物料编码' '80' ,
'CHARG' '批次' '80' ,
'LABST' '数量' '80' ,
'FACT' 'MES工厂' '80' ,
'EXTIME' '货架过期日期' '80' ,
'TYPE' '当前状态' '80' ,
'MESSAGE' '状态文本' '80' .
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_set_layout
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_set_layout .
gs_layout-cwidth_opt = 'X'.
gs_layout-zebra = 'X'.
gs_layout-no_toolbar = 'X'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form Filter_data
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM Filter_data .
SORT zwb_log_t BY werks lgort matnr.
"宁波厂的WLP要分开发
LOOP AT zwb_log_t ASSIGNING FIELD-SYMBOL(<fs>) GROUP BY ( fact = <fs>-fact ).
CLEAR:ls_acc_input.
ls_acc_input-pdmaterial_data-id = sy-datum && sy-uzeit.
LOOP AT zwb_log_t INTO zwb_log_s WHERE fact = <fs>-fact
AND type IS INITIAL.
zmm20pdmaterial_result_item-mat_id = zwb_log_s-matnr.
zmm20pdmaterial_result_item-mat_lot = zwb_log_s-charg.
zmm20pdmaterial_result_item-fac = zwb_log_s-fact.
zmm20pdmaterial_result_item-ck = zwb_log_s-lgort.
zmm20pdmaterial_result_item-qty = zwb_log_s-labst.
zmm20pdmaterial_result_item-e_eate = zwb_log_s-extime.
APPEND zmm20pdmaterial_result_item TO ls_acc_input-pdmaterial_data-input-pdmaterial_result_item .
ENDLOOP.
* 测试端口是否连通
CLEAR lv_err_msg.
CLEAR lcx_ex.
CLEAR ls_acc_output.
IF lcl_zmm20 IS INITIAL.
TRY.
CREATE OBJECT lcl_zmm20
EXPORTING
logical_port_name = 'ZM20WEBSV'. "逻辑端口名称
CATCH cx_ai_system_fault INTO lcx_ex .
ENDTRY.
ENDIF.
IF NOT lcx_ex IS INITIAL.
MESSAGE '远程连接生管系统失败,请联系管理员!' TYPE 'S' DISPLAY LIKE 'E'.
EXIT.
ELSE.
TRY.
CALL METHOD lcl_zmm20->get_pdmaterial_data
EXPORTING
input = ls_acc_input
IMPORTING
output = ls_acc_output.
CATCH cx_ai_system_fault INTO lcx_ex.
CALL METHOD lcx_ex->get_text
RECEIVING
result = lv_err_msg.
ENDTRY.
IF lv_err_msg IS NOT INITIAL.
"接口异常
MESSAGE lv_err_msg TYPE 'S' DISPLAY LIKE 'E'.
EXIT.
ELSEIF ls_acc_output-get_pdmaterial_data_result-message_type = 'E' .
"错误返回消息记录日志
MESSAGE ls_acc_output-get_pdmaterial_data_result-message_text TYPE 'S' DISPLAY LIKE 'E'.
IF ls_acc_output-get_pdmaterial_data_result-message_text CA '违反唯一约束条件'.
LOOP AT zwb_log_t INTO zwb_log_s WHERE fact = <fs>-fact
AND type IS INITIAL.
zwb_log_s-type = 'E'.
zwb_log_s-message = '违反唯一约束条件'.
zwb_log_s-datum = sy-datum.
zwb_log_s-uzeit = sy-uzeit.
MODIFY zwb_log_t FROM zwb_log_s.
ENDLOOP.
ELSE.
LOOP AT zwb_log_t INTO zwb_log_s WHERE fact = <fs>-fact
AND type IS INITIAL.
zwb_log_s-type = 'E'.
zwb_log_s-message = ls_acc_output-get_pdmaterial_data_result-message_text.
zwb_log_s-datum = sy-datum.
zwb_log_s-uzeit = sy-uzeit.
MODIFY zwb_log_t FROM zwb_log_s.
ENDLOOP.
ENDIF.
EXIT.
ELSEIF ls_acc_output-get_pdmaterial_data_result-message_type = 'S' .
LOOP AT zwb_log_t INTO zwb_log_s WHERE fact = <fs>-fact
AND type IS INITIAL.
zwb_log_s-type = 'S'.
zwb_log_s-message = '已盘点完成'.
zwb_log_s-datum = sy-datum.
zwb_log_s-uzeit = sy-uzeit.
MODIFY zwb_log_t FROM zwb_log_s.
ENDLOOP.
ENDIF.
ENDIF.
ENDLOOP.
IF lv_x = ''.
INSERT zwb_log FROM TABLE zwb_log_t.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_show_alv
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_show_alv .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-cprog
i_callback_pf_status_set = 'SUB_STATUS_SET'
i_callback_user_command = 'SUB_USER_COMMAND'
* I_GRID_SETTINGS = GS_SETTING "编辑回填数据时候打开
is_layout_lvc = gs_layout
it_fieldcat_lvc = gt_fieldcat
i_save = 'A'
TABLES
t_outtab = zwb_log_t
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suGT_OUTle error handling here
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SUB_STATUS_SET
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM sub_status_set USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'STATUS01'.
* set titlebar 'TITLE'.
ENDFORM. "SUB_STATUS_SET
*&---------------------------------------------------------------------*
*& Form SUB_USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM sub_user_command USING s_ucomm TYPE sy-ucomm
re_selfield TYPE slis_selfield.
* 修改Alv表的数据实时刷新,并在内表中显示修改的内容
DATA: lr_grid TYPE REF TO cl_gui_alv_grid,
myindex TYPE sy-tabix.
* 刷新屏幕
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lr_grid.
CALL METHOD lr_grid->check_changed_data.
lr_grid->set_frontend_layout( is_layout = gs_layout ). "防止LAYOUT失效
re_selfield-col_stable = 'X'.
re_selfield-row_stable = 'X'.
re_selfield-refresh = 'X'.
CASE s_ucomm.
WHEN '&OUT'.
IF lv_x = ''.
SELECT SINGLE werks FROM zwb_log WHERE datum BETWEEN @lv_data1 AND @lv_data2 AND werks = @s_werks1 INTO @DATA(lv_werks).
IF lv_werks IS NOT INITIAL.
MESSAGE '工厂:' && lv_werks && '已经盘料!!!' TYPE 'E'.
ELSE.
PERFORM filter_data.
ENDIF.
lv_x = 'X'.
ELSE.
MESSAGE '不允许再次点击发送盘点数据' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
WHEN '&DOWNLOAD'.
PERFORM download_excel.
ENDCASE.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form DOWNLOAD_EXCEL
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM download_excel .
MOVE-CORRESPONDING zwb_log_t TO zwb_log_excel.
DELETE zwb_log_excel WHERE type = 'S'.
DELETE zwb_log_excel WHERE type = ''.
SORT zwb_log_excel BY charg.
PERFORM frm_set_fieldname USING '工厂'.
PERFORM frm_set_fieldname USING '储存地点'.
PERFORM frm_set_fieldname USING '物料编码'.
PERFORM frm_set_fieldname USING '批次'.
PERFORM frm_set_fieldname USING '数量'.
PERFORM frm_set_fieldname USING 'MES工厂'.
PERFORM frm_set_fieldname USING '货架过期日期'.
PERFORM frm_set_fieldname USING '当前状态'.
PERFORM frm_set_fieldname USING '状态文本'.
PERFORM frm_set_fieldname USING '建立日期'.
DATA lv_file TYPE string.
DATA:p_files TYPE rlgrap-filename .
p_files = s_werks1 && '工厂盘点异常数据'.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = p_files "默认文件名称
* DEF_PATH = ' ' "默认文件路径
mask = ',excel.xls,*.xls,excel.xlsx,*.xlsx,text.txt,*.txt.'
mode = 'S' "s 保存 ; o打开
title = '保存文件' "窗口显示名称
IMPORTING
filename = lv_file
* RC =
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = lv_file
filetype = 'DAT' "ASC格式 1000- 不会显示为 -1000 DBF格式 字符前空格 前导0不会显示
codepage = '8404' "四位字符集代码 可通过表TCP00A,查询对应字符集代
TABLES
data_tab = zwb_log_excel "内表数据
fieldnames = lt_fieldname. "表头字段名
ENDFORM.
FORM frm_set_fieldname USING VALUE(p_fieldname). "控制获取的字段名
lt_fieldname = p_fieldname.
APPEND lt_fieldname.
ENDFORM.