首页 > 代码库 > 20170111 ABAP技术小结(全半角转换)

20170111 ABAP技术小结(全半角转换)

DATA: it_po LIKE it_alv OCCURS 0 WITH HEADER LINE.
********************************************************************************************
TSTC SAP 事务代码表
********************************************************************************************
CENTERED
********************************************************************************************
合并请求的方法: 选中请求点击菜单上的实用程序->重新组织->合并请求
********************************************************************************************
FIELD-SYMBOLS: <I> TYPE I.
DATA: I1 TYPE I, I2 TYPE I.
ASSIGN I1 TO <I>.
I2 = <I>.
********************************************************************************************
* Range to be deleted: 450 .. 550
DELETE ITAB FROM 450 TO 550.
********************************************************************************************
I = 250.
INSERT LINES OF ITAB1 INTO ITAB2
INDEX I.
********************************************************************************************
APPEND LINES OF ITAB1 TO ITAB2.
将ITAB1中的数据一一对应到ITAB2中,两个内表可以结构不同,不用放在LOOP中
********************************************************************************************
LOOP AT ITAB1 INTO WA.
COLLECT WA INTO ITAB2.
ENDLOOP.
SORT ITAB2 BY K.
********************************************************************************************
READ TABLE ITAB INTO WA
WITH KEY K = ‘X‘.
********************************************************************************************
APPEND WA TO ITAB.
********************************************************************************************
UPDATE SFLIGHT
SET SEATSOCC = SEATSOCC - 1.
********************************************************************************************
DATA: MAX_MSGNR type t100-msgnr.
SELECT MAX( MSGNR ) FROM T100 INTO max_msgnr
WHERE SPRSL = ‘D‘ AND
ARBGB = ‘00‘.
********************************************************************************************
读工艺路线的text
CALL FUNCTION ‘READ_TEXT‘
EXPORTING
client = sy-mandt
id = ‘AVOT‘
language = sy-langu
name = lc_tdname
object = ‘AUFK‘
TABLES
lines = it_tline
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
********************************************************************************************
CDHDR table 更改凭证抬头 主数据有更改的记录 通过OBJECTID link
********************************************************************************************
DATA it_tab TYPE STANDARD TABLE OF mara WITH HEADER LINE.
********************************************************************************************
WRITE l_count TO it_tail-line_items_number LEFT-JUSTIFIED.
********************************************************************************************
SY-DBCNT DB operations, number of table lines processed ZSDR00033F01
********************************************************************************************
AND vbuk~vbtyp = ‘J‘ "DN
AND vbuk~wbstk = ‘C‘ "PGI finished
********************************************************************************************
Dir Path: 
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_patch.
PERFORM get_download_path CHANGING p_patch.

FORM get_download_path CHANGING p_file LIKE rlgrap-filename.
DATA: l_path TYPE string.
DATA: l_len TYPE i.
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
window_title = ‘Select Your Folder‘
CHANGING
selected_folder = l_path
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE ‘S‘ NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
MOVE l_path TO p_file.
l_len = STRLEN( l_path ).
IF l_len > 3.
CONCATENATE p_file ‘‘ INTO p_file.
ENDIF.
ENDFORM. " get_download_path
********************************************************************************************
FORM format_data. ZIMR00047F01 格式轉換 从内表到文件
LOOP AT it_strloc.
PERFORM fields_to_line_by_indicator
USING it_tloc-f1 it_strloc c_indicator.
APPEND it_tloc.
ENDLOOP.
ENDFORM. "format_data

FORM fields_to_line_by_indicator USING p_line
p_tab
p_seperator.
DATA: l_line TYPE string.
FIELD-SYMBOLS: <f>.
CLEAR: p_line.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE p_tab TO <f>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
IF sy-index = 1.
p_line = <f>.
ELSE.
l_line = <f>.
CONDENSE l_line.
CONCATENATE p_line p_seperator l_line INTO p_line.
ENDIF.
ENDDO.
ENDFORM. "fields_to_line_by_indicator
********************************************************************************************
*&Get Standard Cost FROM mbew
********************************************************************************************
write时将‘-‘号提前
PERFORM change_qty USING l_srqty 
CHANGING it_inv-srqty.

FORM change_qty USING p_qty
CHANGING p_qty1.
p_qty1 = p_qty.
SHIFT p_qty1 LEFT DELETING LEADING ‘ ‘.
SHIFT p_qty1 UP TO ‘-‘ LEFT CIRCULAR.
CONDENSE p_qty1 NO-GAPS.
ENDFORM. " change_qty
********************************************************************************************
目的:将字符串尾的负号放在字符串首
CALL FUNCTION ‘CLOI_PUT_SIGN_IN_FRONT‘
CHANGING
value = http://www.mamicode.com/itab-amunt.
********************************************************************************************
CONCATENATE sy-datum(4) ‘-‘ sy-datum+4(2) ‘-‘ sy-datum+6(2) INTO it_stock-date.
********************************************************************************************
IF it_itab-zzalc IS NOT INITIAL.
DO 12 TIMES.
l_num = sy-index - 1.
ASSIGN it_itab-zzalc+l_num(1) TO <char>.
CONCATENATE l_text <char> cl_abap_char_utilities=>horizontal_tab INTO l_text.
ENDDO.
SPLIT l_text AT cl_abap_char_utilities=>horizontal_tab
INTO it_itab-digit1
it_itab-digit2
it_itab-digit3
it_itab-digit4
it_itab-digit5
it_itab-digit6
it_itab-digit7
it_itab-digit8
it_itab-digit9
it_itab-digit10
it_itab-digit11
it_itab-digit12.
ENDIF.
********************************************************************************************
PERFORM get_standard_price_from_mbew
SELECT SINGLE w~bwkey t~waers
INTO (t001w-bwkey,p_waers)
FROM t001w AS w INNER JOIN t001k AS k ON w~bwkey = k~bwkey
INNER JOIN t001 AS t ON k~bukrs = t~bukrs
WHERE w~werks = p_werks.
SELECT SINGLE stprs peinh
INTO (p_netpr,p_peinh)
FROM mbew
WHERE matnr = p_matnr
AND bwkey = t001w-bwkey.
********************************************************************************************
PARAMETERS p_pwd(30) TYPE c LOWER CASE DEFAULT ‘sapuser‘ OBLIGATORY,
LOOP AT SCREEN.
IF screen-name = ‘P_PWD‘.
screen-invisible = ‘1‘.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
輸出時讓password顯示為******
********************************************************************************************
UPDATE zimpiccma0002
SET stats = ‘1‘ numla = g_lastnum
WHERE gjahr = p_gjahr
AND verso = p_verso
AND werks = p_werks.
********************************************************************************************
DD_DOMA_GET or DDIF_DOMA_GET 取 domain的FN 
DD07V 取 domain的table 
********************************************************************************************
check 是否是NUM型
CALL FUNCTION ‘CATS_NUMERIC_INPUT_CHECK‘
********************************************************************************************
CALL FUNCTION ‘CY_IS_INTEGER‘
EXPORTING
string_to_be_checked = it_tab-new
EXCEPTIONS
not_an_integer = 01.
IF sy-subrc <> 0.
CONCATENATE ‘In-house production must be integer‘ ‘.‘
********************************************************************************************
LOOP AT it_table2 WHERE belnr = it_wa-lfbnr
AND buzei = it_wa-lfpos.
IF l_shkzg = ‘H‘.
it_table2-mengr = it_table2-mengr - it_wa-menge.
ELSE.
it_table2-mengr = it_table2-mengr + it_wa-menge.
ENDIF.
MODIFY it_table2.
CLEAR it_table2.
ENDLOOP.
********************************************************************************************
CONCATENATE it_header-line ‘,‘ cl_abap_char_utilities=>newline INTO it_header-line. 换行
********************************************************************************************
FORM get_tab_char .
DATA l_string(1024).
CALL FUNCTION ‘STPU1_HEX_TO_CHAR‘
EXPORTING
hex_string = ‘X9‘
IMPORTING
char_string = l_string.
g_tab = l_string.
ENDFORM. " get_tab_char
********************************************************************************************
RANGES r_lgort FOR ekpo-lgort. ZSDR00036 
SELECT sign opti AS option low high 
INTO CORRESPONDING FIELDS OF TABLE r_lgort
FROM tvarvc
WHERE name = ‘MM__RT_PRCODE‘.

*&avoid show dump when range fields ‘sign‘ and ‘option‘ is intial
DELETE r_lgort WHERE sign IS INITIAL OR option IS INITIAL. 
********************************************************************************************
WRITE l_temp TO p_fdate USING EDIT MASK ‘ ____/__/__‘.

AND VBTYP NOT IN (‘N‘,‘S‘). 
********************************************************************************************
DATA: l_datum(8) TYPE c.
l_datum = sy-datum. "ES 070301
l_datum+6(2) = ‘01‘.
********************************************************************************************
call Function ‘KD_GET_FILENAME_ON_F4‘ 上传文件控制文件类型
msak = ‘*.xls‘ 
********************************************************************************************
check全角or半角的方法
第一种方法
SJIS_DBC_TO_SBC 全角转半角 
SJIS_SBC_TO_DBC 半角转换为全角 
设定 import 
all =x
text = 文本
全角-〉半角,返回值 1
全角-〉全角 返回值0
第二种方法
REPORT ZZXIAOXIN0999.
DATA: last_ascii_zf(2) TYPE x value ‘00FF‘. "unicode MIT
DATA: last_ascii_en(2) TYPE x value ‘A100‘. "unicode MIT
data char(33) type c.
data: point(2) type x.
char = ‘ssss‘.
point = cl_abap_conv_out_ce=>uccp( char ).
if point <= last_ascii_zf.
else.
write ‘double byte char‘.
endif.
********************************************************************************************
table T247 Month name and short text
********************************************************************************************
SELECT DISTINCT bukrs
INTO TABLE lt_bukrs
FROM t001
WHERE bukrs IN s_bukrs.
加上[DISTINCT]会自动去除重复的记录 ZFIR00025
********************************************************************************************
***** 1: 補零 2. 去零
call function ‘CONVERSION_EXIT_ALPHA_INPUT‘
call function ‘CONVERSION_EXIT_ALPHA_OUTPUT‘
********************************************************************************************
IF w_infor-datab NOT BETWEEN l_minus_datab AND l_plus_datab.
DAY_IN_WEEK 求今天星期幾
********************************************************************************************
IF it_zppasbuma0001[] IS NOT INITIAL. ZPPE0002 出數據
no_update = ‘X‘.
EXPORT it_zppasbuma0001[] TO MEMORY ID ‘ZPPASBUMA0001‘.
SUBMIT zppr00067 AND RETURN.
FREE MEMORY ID ‘ZPPASBUMA0001‘.
ENDIF.

IMPORT it_zppasbuma0001[] FROM MEMORY ID ‘ZPPASBUMA0001‘. ZPPR00067 接數據

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

w_message1 = ‘Physical inventory counting is on going,‘.
w_message2 = ‘change is not allowed‘.
MESSAGE ID ‘ZPP01‘ TYPE ‘I‘ NUMBER 000
WITH w_message1 w_message2.

********************************************************************************************
*& Get House Waybill Number.
SELECT SINGLE zhawb INTO (it_ship-zhawb) FROM zsdps00mp0024
WHERE vbeln = it_ship-vbeln.
IF s_zhawb[] IS NOT INITIAL.
IF sy-subrc = 0.
IF it_ship-zhawb NOT IN s_zhawb.
DELETE it_ship.
CONTINUE.
ENDIF.
ELSE.
DELETE it_ship.
CONTINUE.
ENDIF.
ENDIF.
********************************************************************************************
p_site = ‘123_ _ _abc ’._是空格的意思,就是我现在里面有三个空格。如果是CONDENSE p_site。
那么p_site = ‘123_abc ’.如果是CONDENSE p_site NO-GAPS。那么p_site = ‘123abc ’.

CONCATENATE ‘IEQ‘ sy-datum(6) ‘01‘ sy-datum INTO l_date . 求本月第一天
********************************************************************************************
1 TRANSLATE p_maktx USING ‘, ‘.
CONDENSE p_maktx.

2 DATA text TYPE string.
text = `BarbcBdbara`.
TRANSLATE text USING ‘ABBAabbM‘. CONDENSE text.
write text. 結果 AbrMcAdMbrb ZBAMA003 
********************************************************************************************

*&Generate File 
PERFORM z_ftp_layout(zbar00004) TABLES it_char ---> ZPPR00034
USING c_code
p_berid
g_filename
CHANGING g_retcd.

CLEAR g_retcd.
PERFORM z_ftp_layout(zbar00008) TABLES it_char --->ZIMR00057F01 ZIMR00061 ZIMR00046F01
USING ‘DASHBOARD‘
p_werks
l_fname
CHANGING l_tetcd. 產生file的公用form
********************************************************************************************
TYPE pos TYPE i. 
SEARCH s_email-low FOR ‘@‘ STARTING AT pos. 從第pos個字符開始尋找 
********************************************************************************************
..WHERE NAME LIKE ‘LEE%’.
条件为NAME字段前3个字符为 LEE
..WHERE MODEL NOT LIKE ‘‘%SPS%’.
条件为MODEL字段不包含 SPS的记录
IF it_index-kursf_16 IS INITIAL AND it_index-blart(1) = ‘Z‘. Z開頭的記錄

********************************************************************************************
*& get the max sequence long text
SORT tmp_zsdwomsde0011 BY vbeln posnr zcopo tdid DESCENDING zzseqn.
DELETE ADJACENT DUPLICATES FROM tmp_zsdwomsde0011 COMPARING vbeln posnr zcopo tdid.
********************************************************************************************
DATLO Date and time, local date of user
TIMLO
lt_data-erdat = sy-datum. Current (Application Server) Date
lt_data-erzet = sy-uzeit.
********************************************************************************************
SPLIT p_value AT ‘/‘ INTO l_year l_month l_day.
********************************************************************************************
ftp 命令
CONCATENATE ‘cd‘ p_folder INTO l_cmd SEPARATED BY space . Change Current Folder
CONCATENATE ‘mkdir‘ p_folder INTO l_cmd SEPARATED BY space . *& Create A Folder
CONCATENATE ‘del‘ p_ftp_filename INTO l_cmd SEPARATED BY space. Delete a file
CONCATENATE ‘rename‘ g_filename_tmp p_filename INTO l_cmd SEPARATED BY space. Rename a file
********************************************************************************************
data ip_addr(20) type c. get local IP address 如果字符不定义长度,那么默认为1码。 
CALL METHOD cl_gui_frontend_services=>get_ip_address 
RECEIVING
ip_address = ip_addr.
write : ip_addr.
********************************************************************************************
PERFORM get_desc USING it_data-matnr 取母件和子件描述的方法 ZPPR00040
CHANGING it_report-maktx.
PERFORM get_desc USING it_data-idnrk
CHANGING it_report-cmaktx.
********************************************************************************************
RANGES: r_lifnr FOR ekko-lifnr. ZIMR00058TOP
LOOP AT it_vendorno.
CONCATENATE ‘IEQ‘ it_vendorno-lifnr INTO r_lifnr.
APPEND r_lifnr.
ENDLOOP.
********************************************************************************************
SHIFT it_trans-lifnr LEFT DELETING LEADING ‘0000000000‘. 如果lifnr的值是0000123,运行之后的结果是123.去0操作
********************************************************************************************
PERFORM get_asc_code(zbar00004) CHANGING g_tab. ZIMR00016转换TAB键
********************************************************************************************
SPLIT it_load AT cl_abap_char_utilities=>horizontal_tab
INTO it_itab-werks
it_itab-bsart
it_itab-ebeln
it_itab-ebelp
it_itab-eindt. TAB 
********************************************************************************************
TRANSLATE g_fpath TO LOWER CASE. 将g_fpath这个变量的值转换成小写
TRANSLATE g_fpath TO UPPER CASE. 将g_fpath这个变量的值转换成大写
********************************************************************************************
IF NOT l_elikz <> ‘X‘.
CONTINUE.
ENDIF.

IF l_elikz = ‘X‘.
CONTINUE.
ENDIF.
结果相同
********************************************************************************************
MESSAGE ‘sucess message‘ TYPE ‘S‘ DISPLAY LIKE ‘E‘. 实现SHOW ERROR MESSAGE,而不用跳转屏幕.
********************************************************************************************
IF sy-subrc <> 0.
SET CURSOR FIELD p_werks. 光标定位
MESSAGE e000 WITH ‘No Authority for Plant‘ p_werks.
ENDIF.
********************************************************************************************
SET CURSOR FIELD zpppiccma0001-werks. 设置光标到这个栏位上
********************************************************************************************
* DATA it_mara TYPE STANDARD TABLE OF st_mara WITH HEADER LINE. 定义标准表
********************************************************************************************
SELECT LIPS~WERKS LIPS~MATNR MAKT~MAKTX AS ARKTX
LIPS~LGORT LIPS~MEINS
SUM( LIPS~LFIMG ) AS LFIMG_T
INTO CORRESPONDING FIELDS OF TABLE P_HEADER[]
FROM LIKP
INNER JOIN LIPS
ON LIKP~VBELN = LIPS~VBELN
LEFT JOIN MAKT
ON LIPS~MATNR = MAKT~MATNR AND MAKT~SPRAS = C_LANG
INNER JOIN VBUP
ON VBUP~VBELN = LIPS~VBELN AND VBUP~POSNR = LIPS~POSNR
AND VBUP~WBSTA <> C_DN_STATUS
WHERE LIPS~WERKS IN S_WERKS AND LIKP~LFART IN S_LFART
AND LIKP~WADAT BETWEEN L_DATE
AND S_WADAT-HIGH
GROUP BY LIPS~WERKS LIPS~MATNR MAKT~MAKTX LIPS~LGORT
LIPS~MEINS
ORDER BY LIPS~WERKS LIPS~MATNR MAKT~MAKTX LIPS~LGORT
LIPS~MEINS .
********************************************************************************************
SELECT SUM( LABST ) SUM( INSME )
INTO (IT_ALV-LABST,IT_ALV-INSME)
FROM MARD
WHERE MATNR = P_MATNR
AND WERKS = P_WERKS
AND LGORT IN R_LGORT.
********************************************************************************************
CONCATENATE sy-timlo(2) ‘:‘ sy-timlo+2(2) ‘:‘ sy-timlo+4(2) INTO l_time .
结果 11:19:31
********************************************************************************************
POPRC TYPE P08_AWE_DEC18_5, "(17)PO Price Data element(数据元素)
********************************************************************************************
ON CHANGE OF IT_TABLE1-MATNR.
L_FINDTIMES = 0.
ENDON.
********************************************************************************************
IF S_MFRNR IS NOT INITIAL.
DELETE IT_TABLE1 WHERE MFRNR NOT IN S_MFRNR.
ENDIF.
如果S_MFRNR = x 。那么会DELETE S_MFRNR <> X.
********************************************************************************************
l_pwd_len = STRLEN( password ).
********************************************************************************************
MOVE-CORRESPONDING it_plant TO it_tab. 要放入LOOP中
MOVE it_plant-ftp TO it_tab-ftp.
********************************************************************************************
取第一条数据到一个工作区中。
READ TABLE it_tab INDEX 1 INTO wa_tab.

READ TABLE ta_mkpf WITH KEY mblnr = ta_mseg-mblnr BINARY SEARCH.
加上BINARY SEARCH.速度会快很多
********************************************************************************************
根据采购定单45开头ebeln itab0-ebeln+0(2) = ‘45‘.
********************************************************************************************
WRITE : /1(124) sy-uline . sy-vline no-zero 去‘0‘
WRITE后跟NO-GAP表示压缩空格,WRITE 后跟no-ZERO表示不显示0.
WRITE: ‘No‘ NO-GAP, ‘Gap‘.
********************************************************************************************
modify it_material transporting eknam.
********************************************************************************************
PARAMETERS : s_fname LIKE rlgrap-filename OBLIGATORY MEMORY ID p04.

"把s_fname的值存入记忆体,下面在用时会自动载入这一次的值

SELECTION-SCREEN ULINE. "画横线

SELECTION-SCREEN SKIP 1.

DEFAULT SY-DATUM+0(4) 20061010 选前四位 2006

s_bldat FOR mkpf-bldat DEFAULT sy-datum TO sy-datum,

hkont-sign = ‘I‘.
hkont-option = ‘EQ‘.
hkont-low = ‘0051010100‘.
append hkont.
********************************************************************************************
default ‘1000‘ 默认值
obligatory 必输项
NO INTERVALS 单值,没有间隔
no-extension 限制选择表为单行 选择屏幕上不出现->图标
********************************************************************************************
wa_vbak-vbeln = ‘111111x‘.
wa_vbak-erdat = ‘20061111‘.
APPEND wa_vbak to itab_vbak.
********************************************************************************************
wa_vbak-vbeln = ‘111111y‘.
wa_vbak-erdat = ‘20061110‘.
INSERT wa_vbak INTO TABLE itab_vbak.
********************************************************************************************
wa_vbak-vbeln = ‘111111z‘.
wa_vbak-erdat = ‘20060202‘.
MODIFY itab_vbak FROM wa_vbak TRANSPORTING vbeln erdat where vbeln = ‘111111z‘.
********************************************************************************************
DELETE ADJACENT DUPLICATES FROM itab_vbak COMPARING vbeln posnr. 
DELETE itab_vbak 中vbeln、posnr记录相同的记录
********************************************************************************************
FOR ALL ENTRIES IN ntable
********************************************************************************************
at new matkl.
new-page. "按物料组分页
endat.

at end of matkl. "按物料组打印
new-page.
endat.
********************************************************************************************
S: 借 在计算的时候记为负
H: 贷 在计算的时候记为正

select __ from __ where matnr like ‘1%%%04%‘. 
********************************************************************************************
1 或 COL_HEADING 灰蓝 标题
2 或 COL_NORMAL 淡灰 列表正文
3 或 COL_TOTAL 黄 总计
4 或 COL_KEY 蓝绿 关键字列
5 或 COL_POSITIVE 绿 正门限值
6 或 COL_NEGATIVE 红 负门限值
7 或 COL_GROUP 紫 组级别

WRITE: ‘AAAA‘ COLOR 5 INVERSE CENTERED. 字體加色彩并居中
********************************************************************************************
前4條記錄
SELECT * INTO wa FROM scarr UP TO 4 ROWS. 
********************************************************************************************
ALV 表头加图片
call function ‘REUSE_ALV_COMMENTARY_WRITE‘
exporting
it_list_commentary = G_LIST_TOP_OF_PAGE
i_logo = ‘ENJOYSAP_LOGO‘ 
i_end_of_list_grid = ‘X‘.

在layout中用
l_s_layout-info_fieldname = ‘COLOR‘. 行色彩. first 在内表中定义一个 COLOR(4) TYPE C, then 用 if在内表中作判断
IT_LAYOUT-grid_title = ‘Material Master‘(010). 列头output
IT_LAYOUT-COLWIDTH_OPTIMIZE = ‘X‘. 优化列宽
IT_LAYOUT-zebra = ‘X‘. 能隔行换色(斑马线)
IT_LAYOUT-box_fieldname = ‘SELECTED‘. 第一行的前面是否有挑选行 当MOUSE MOVE到这一列中只可以选中单元格
先定义 G_F2CODE LIKE SY-UCOMM VALUE ‘&ETA‘, 然后 IT_LAYOUT-F2CODE = G_F2CODE. 可以让ALV显示一行的明细
********************************************************************************************
在output中用
ls_fieldcat-DO_SUM = ‘X‘ 求小計
fc_detail-no_zero = ‘X‘. 去前面的0
fc_detail-just = ‘C‘. 参数有C中L左F右 对齐方式 
fc_detail-emphasize = ‘C411‘ . 列色彩 参数有C411C511C611C711 从1到7
ls_fieldcat-hotspot = ‘X‘.
wa_alvlayout-window_titlebar = sy-title.
wa_fieldcat-fix_column = &6. 固定列
wa_fieldcat-cfieldname BY 金额
wa_fieldcat-qfieldname BY 单位

ALV中的数据怎么自动刷新
in the form "user_command", there is one changing variant TYPE SLIS_SELFIELD, you can set SLIS_SELFIELD-REFRESH = ‘X‘.
********************************************************************************************
REPLACE ‘//‘ WITH ‘/‘ INTO g_fpath.
********************************************************************************************
Describe table itab lines line . 
********************************************************************************************
FORM check_plant .

SELECT SINGLE *
FROM t001w
WHERE werks = s_werks-low.

IF sy-subrc <> 0.
MESSAGE s398 WITH ‘Plant ‘ s_werks-low ‘is not exist!‘.
STOP.
ELSE.
IF s_werks-high IS NOT INITIAL.
SELECT SINGLE *
FROM t001w
WHERE werks = s_werks-high.
IF sy-subrc <> 0.
MESSAGE s398 WITH ‘Plant ‘ s_werks-high ‘is not exist!‘.
STOP.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " check_plant
********************************************************************************************
Check current user has the authorization required for plant field
PERFORM check_user_authority.

FORM check_user_authority .
DATA: BEGIN OF lt_werks OCCURS 0,
werks TYPE t001w-werks,
END OF lt_werks.

SELECT DISTINCT werks
INTO TABLE lt_werks
FROM t001w
WHERE werks IN s_werks.

LOOP AT lt_werks.
AUTHORITY-CHECK OBJECT ‘M_BEST_WRK‘
ID ‘WERKS‘ FIELD lt_werks-werks
ID ‘ACTVT‘ FIELD ‘03‘.
IF sy-subrc <> 0.
MESSAGE s398 WITH ‘Plant ‘ lt_werks-werks ‘ have no authorization to query.‘.
STOP.
ENDIF.
ENDLOOP.

ENDFORM. " check_user_authority
********************************************************************************************
URL_HEAD = ‘http://192.168.0.8/matnr/‘.
E_MATNR = VBAP-MATNR.
URL_FOOT = ‘.JPG‘.
CONCATENATE URL_HEAD E_MATNR URL_FOOT INTO URL.
CONDENSE URL NO-GAPS.
********************************************************************************************
PARAMETERS: p_days TYPE i DEFAULT 15 MODIF ID 001.
SELECT-OPTIONS: s_st_del FOR zppbomphd0001-zstatus
DEFAULT ‘S‘ OPTION EQ SIGN I
MODIF ID 001.
设置 MODIF ID 001 当T-code是ZPP002L时,可以将p_days and s_st_del hide
AT SELECTION-SCREEN OUTPUT. 以下CODE要放在这个事件的下面
PERFORM check_screen_output.
FORM check_screen_output .
IF sy-tcode = ‘ZPP002L‘.
LOOP AT SCREEN.
IF screen-group1 = ‘001‘.
screen-input = 0.
screen-invisible = 1.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. " check_screen_output

at selection-screen output. ZPUR00002
loop at screen.
if screen-name = ‘P_FNAME‘.
if p_excel = ‘X‘.
screen-input = 1.
else.
screen-input = 0.
endif.
modify screen.
endif.
endloop.
********************************************************************************************
SELECT * FROM sflight
INTO CORRESPONDING FIELDS OF wa_flight.
APPEND wa_flight TO it_flight.
ENDSELECT.
********************************************************************************************
loop at t_report.
move-corresponding t_report to t_alv.
append t_alv.
clear t_alv.
endloop.
********************************************************************************************
货币转换 CALL FUNCTION ‘CONVERT_TO_FOREIGN_CURRENCY‘ 
******************************************************************************************** 
DATA: BEGIN OF it_out OCCURS 0.
INCLUDE STRUCTURE zimamlma0001.
DATA: chb(1) TYPE c,
END OF it_out.
********************************************************************************************
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: c_suces AS CHECKBOX.
SELECTION-SCREEN COMMENT (12) text-001 FOR FIELD c_suces. 当单击 text-001会选中c_suces
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(18) text-r01.
PARAMETERS: p_grpp RADIOBUTTON GROUP g1 DEFAULT ‘X‘ USER-COMMAND com1.
SELECTION-SCREEN COMMENT 23(20) text-r02 FOR FIELD p_grpp.
SELECTION-SCREEN END OF LINE.
********************************************************************************************
SELECT DISTINCT seqnr
APPENDING TABLE lt_out
FROM zimamlma0001
WHERE bmatn IN s_matnr
AND mfrnr IN s_mfrnr
AND cdate IN s_datum
AND zampls = ‘2‘.
APPENDING新增加记录,如果用INTO就会覆盖以前的记录
********************************************************************************************
DELETE ADJACENT DUPLICATES FROM lt_output COMPARING mblnr mjahr zeile. 
DELETE LT_OUTPUT中 mblnr mjahr zeile 值完全相同的记录

sort table it_index by matnr.

LOOP AT it_index.
CLEAR l_flag.
AT END OF matnr.
l_flag = ‘X‘.
ENDAT.
IF l_flag = ‘X‘.
it_index-tmenge = it_index-tmenge + it_index-menge.
MODIFY it_index TRANSPORTING tmenge WHERE matnr = it_index-matnr.
CLEAR: it_index.
ENDIF.
ENDLOOP.

20170111 ABAP技术小结(全半角转换)