ABAP 鍐呰〃鐨勮鍒楄浆鎹?鍙戣揣閫氱煡鍗?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ABAP 鍐呰〃鐨勮鍒楄浆鎹?鍙戣揣閫氱煡鍗?相关的知识,希望对你有一定的参考价值。

鏍囩锛?/p>

*&---------------------------------------------------------------------*
*& Report  Z_TEST_COL_TO_ROW_02
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT Z_TEST_COL_TO_ROW_02.
TABLES: VTTP,LIPS,LIKP,KNA1 ,VTTK.

DATA: gs_fcat TYPE lvc_s_fcat,
      gt_fcat TYPE lvc_t_fcat,
      gs_layo TYPE lvc_s_layo,
      gs_grid TYPE lvc_s_glay.
DATA: gt_event TYPE slis_t_event WITH HEADER LINE,
      gt_event_exit TYPE slis_t_event_exit WITH HEADER LINE.

DATA:  ref_grid TYPE REF TO cl_gui_alv_grid .

TYPESBEGIN OF TY_ALL,
      TKNUM LIKE VTTK-TKNUM,"杩愬崟鍙?br />       VBELN LIKE LIPS-VBELN,"浜よ揣鍗曞彿
      TPLST LIKE VTTK-TPLST ,"瑁呰繍鐐?br />       NAME1 LIKE  KNA1-NAME1 ,"瀹㈡埛
      ERDAT LIKE VTTK-ERDAT ,"鍒涘缓鏃ユ湡
      TDLNR LIKE VTTK-TDLNR ,"鐗╂祦鍏徃
      ROUTE LIKE VTTK-ROUTE ,"绾胯矾
      DISTZ LIKE VTTK-DISTZ ,"閲岀▼
      ADD01 LIKE VTTK-ADD01 ,"杞︿富
      EXTI1 LIKE VTTK-EXTI1 ,"鍗歌揣鐐?br />       ADD02 LIKE VTTK-ADD02 ,"鍙告満
      BFART LIKE VTTK-BFART ,"杞﹀帰绫诲瀷
      MATNR LIKE LIPS-MATNR,"鐗╂枡缂栫爜
      ARKTX LIKE LIPS-ARKTX,"鐗╂枡鎻忚堪
      BRGEW LIKE LIPS-BRGEW,"璐х墿鍗曢」鐩瘺閲?br />       LFIMG LIKE LIPS-LFIMG,"鍗曢」鐩暟閲?br />       VRKME LIKE  LIPS-VRKME ,"鍗曚綅
      GEWEI LIKE LIPS-GEWEI,"閲嶉噺鍗曚綅
      LGORT LIKE LIPS-LGORT,"搴撳瓨鍦扮偣
     BEIZHU(30TYPE C,"澶囨敞
END OF TY_ALL.

TYPES:BEGIN OF TY_HEADER,
      TKNUM LIKE VTTK-TKNUM,"杩愬崟鍙?br />       VBELN LIKE LIPS-VBELN,"浜よ揣鍗曞彿
      NAME1 LIKE  KNA1-NAME1 ,"瀹㈡埛
      TPLST LIKE VTTK-TPLST ,"瑁呰繍鐐?br />       ERDAT LIKE VTTK-ERDAT ,"瑁呰繍鏃ユ湡
      TDLNR LIKE VTTK-TDLNR ,"鐗╂祦鍏徃
      ROUTE LIKE VTTK-ROUTE ,"绾胯矾
      DISTZ LIKE VTTK-DISTZ ,"閲岀▼
      ADD01 LIKE VTTK-ADD01 ,"杞︿富
      EXTI1 LIKE VTTK-EXTI1 ,"鍗歌揣鐐?br />       ADD02 LIKE VTTK-ADD02 ,"鍙告満
      BFART LIKE VTTK-BFART ,"杞﹀帰绫诲瀷
      TOTAL_BRGEW LIKE LIPS-BRGEW,"涓€涓氦璐у崟鐨勬€婚噸閲?br />     END OF TY_HEADER.
*鍗曟嵁鎶ご缁撴潫

*鍗曟嵁鏄庣粏寮€濮?br /> TYPES:BEGIN OF TY_ITEMS,
     TKNUM LIKE VTTK-TKNUM,"杩愬崟鍙?br />      VBELN LIKE LIPS-VBELN,"浜よ揣鍗曞彿
     NAME1 LIKE  KNA1-NAME1 ,"瀹㈡埛
     MATNR LIKE LIPS-MATNR,"鐗╂枡缂栫爜
     ARKTX LIKE LIPS-ARKTX,"鐗╂枡鎻忚堪
     BRGEW LIKE LIPS-BRGEW,"鍗曢」鐩瘺閲?br />      GEWEI LIKE LIPS-GEWEI,"閲嶉噺鍗曚綅
     LFIMG LIKE LIPS-LFIMG,"鍗曢」鐩暟閲?br />      VRKME LIKE  LIPS-VRKME ,"鍗曚綅
     LGORT LIKE LIPS-LGORT,"搴撳瓨鍦扮偣
     BEIZHU(30TYPE C,"澶囨敞
    END OF TY_ITEMS.
*鍗曟嵁鏄庣粏缁撴潫

DATA:WA_ALL TYPE TY_ALL,
      GT_ALL TYPE TY_ALL OCCURS 0.

 DATA:WA_HEADER TYPE TY_HEADER,
      GT_HEADER TYPE TY_HEADER OCCURS 0  .

 DATA:WA_ITEMS TYPE TY_ITEMS,
      GT_ITEMS TYPE TY_ITEMS OCCURS 0.

 DATA: GT_HEADER_SHOW TYPE TY_HEADER OCCURS 0.
 DATA: GT_ITEMS_SHOW TYPE TY_ITEMS OCCURS 0.
*瀹氫箟浼犲叆鍒皊martforms鐨勫彉閲忓紑濮?br /> DATA:fm_name TYPE rs38l_fnam.
DATA:itemsname(32TYPE c.
DATA:headername(32TYPE c.
*瀹氫箟浼犲叆鍒皊martforms鐨勫彉閲忕粨鏉?br />

*瀹氫箟瀛樺偍ALV鍚憇martforms浼犲叆鏁版嵁鐨勫唴琛ㄥ紑濮?br /> DATA:GT_HEADER_TEMP TYPE TY_HEADER OCCURS 0.
DATA:GT_ITEMS_TEMP TYPE TY_ITEMS OCCURS 0.
DATA:GT_ALL_TEMP TYPE TY_ALL OCCURS 0.
*瀹氫箟瀛樺偍ALV鍚憇martforms浼犲叆鏁版嵁鐨勫唴琛ㄧ粨鏉?br />
"鎺у埗smartforms鍙傛暟澹版槑寮€濮?br /> DATA :control_parameters TYPE ssfctrlop.
"鎺у埗smartforms鍙傛暟澹版槑缁撴潫

TYPESBEGIN OF ty_sum ,
        MATNR LIKE LIPS-MATNR,"鐗╂枡缂栫爜
        ARKTX LIKE LIPS-ARKTX,"鐗╂枡鎻忚堪
        LFIMG LIKE LIPS-LFIMG,"鍗曢」鐩暟閲?br />         VRKME LIKE  LIPS-VRKME ,"鍗曚綅
       NAME1 LIKE  KNA1-NAME1 ,"瀹㈡埛
       BRGEW LIKE LIPS-BRGEW,"鍗曢」鐩瘺閲?br /> END OF ty_sum.

DATA : itab TYPE  ty_sum OCCURS ."WITH HEADER LINE ."浠庢暟鎹簱涓彇鍑虹殑鏁版斁鍏ョ殑鍐呰〃
DATA : hs_sum TYPE HASHED TABLE OF ty_sum WITH UNIQUE KEY MATNR ARKTX VRKME NAME1 WITH HEADER LINE .
DATA : itab_sum TYPE STANDARD TABLE OF ty_sum WITH HEADER LINE .

DATABEGIN OF itab_out OCCURS 0,"琛屽垪杞崲鍚庣殑鍐呰〃
        MATNR LIKE LIPS-MATNR,"鐗╂枡缂栫爜
        ARKTX LIKE LIPS-ARKTX,"鐗╂枡鎻忚堪
        VRKME LIKE  LIPS-VRKME ,"鍗曚綅
        01 TYPE ,
        02 TYPE ,
        03 TYPE ,
        04 TYPE ,
        05 TYPE ,
        06 TYPE ,
        07 TYPE ,
        08 TYPE ,
        09 TYPE ,
        10 TYPE ,
        11 TYPE ,
        12 TYPE ,
        13 TYPE ,
        14 TYPE ,
        15 TYPE ,
        16 TYPE ,
        17 TYPE ,
        18 TYPE ,
        19 TYPE ,
        20 TYPE ,
        21 TYPE ,
        22 TYPE ,
        23 TYPE ,         
24 TYPE ,         
25 TYPE ,         
26 TYPE ,         line_sum 
TYPE ,         BRGEW_sum 
LIKE LIPS-BRGEW,
END OF itab_out.

TYPESBEGIN OF ty_col ,"瀛樺偍鍔ㄦ€佹樉绀哄垪鐨勫唴琛ㄧ粨鏋?       NAME1 
LIKE  KNA1-NAME1 ,"瀹㈡埛
END OF ty_col.

DATA : hs_col TYPE HASHED TABLE OF ty_col WITH UNIQUE KEY NAME1 WITH HEADER LINE .
DATA : itab_col TYPE STANDARD TABLE OF ty_col WITH HEADER LINE .

FIELD-SYMBOLS: <f_fs1> ,                <f_fs2>
.

START-OF-SELECTION.
SELECT-OPTIONS: P_ERDAT   FOR VTTK-ERDAT ,                 P_TKNUM   
FOR VTTK-TKNUM ,                 P_TDLNR   
FOR VTTK-TDLNR ,                 P_TPLST   
FOR VTTK-TPLST ,                 P_ERNAM   
FOR VTTK-ERNAM ,                 P_ROUTE   
FOR VTTK-ROUTE .

START-OF-SELECTION.
PERFORM getdata.
PERFORM fixdata.
PERFORM outdata.


FORM getdata.   

SELECT *       
FROM VTTK AS VK       INNER 
JOIN VTTP AS VP         
ON VK~TKNUM = VP~TKNUM       INNER 
JOIN LIPS AS L         
ON L~VBELN = VP~VBELN       INNER 
JOIN LIKP AS LP         
ON LP~VBELN = L~VBELN       INNER 
JOIN KNA1 AS K         
ON K~KUNNR = LP~KUNAG       
INTO CORRESPONDING FIELDS OF TABLE GT_ALL       
WHERE             VK

~TKNUM IN  P_TKNUM AND (             VK
~ERDAT IN  P_ERDAT AND             VK
~TDLNR IN  P_TDLNR AND             VK
~TPLST IN  P_TPLST AND             VK
~ERNAM IN  P_ERNAM AND             VK
~ROUTE IN  P_ROUTE .       
SORT GT_ALL ASCENDING BY TKNUM.       
MOVE-CORRESPONDING GT_ALL TO GT_HEADER_SHOW.       
MOVE-CORRESPONDING GT_ALL TO GT_ITEMS_SHOW.       
DELETE ADJACENT DUPLICATES FROM GT_HEADER_SHOW COMPARING TKNUM  .       
MOVE-CORRESPONDING GT_ALL TO itab.
ENDFORM" GETDATA
*&---------------------------------------------------------------------*
*& Form FIXDATA
*&---------------------------------------------------------------------*
FORM fixdata.
DATAindex LIKE sy-tabix .
DATA:wa_itab TYPE  ty_sum.
LOOP AT itab INTO wa_itab.       hs_sum 
= wa_itab.       
COLLECT hs_sum.             hs_col 
= wa_itab-NAME1 .       
COLLECT hs_col.
ENDLOOP.

SORT hs_col.       itab_col[] 
= hs_col[].       itab_sum[] 
= hs_sum[].
LOOP AT itab_sum.     itab_out
-MATNR = itab_sum-MATNR .     itab_out
-ARKTX = itab_sum-ARKTX .     itab_out
-VRKME = itab_sum-VRKME .     
READ TABLE itab_col WITH KEY NAME1 = itab_sum-NAME1 .     
index = sy-tabix + 3."3杩欎釜鏁板瓧浠h〃鏈夊嚑鍒楁槸鍥哄畾涓嶅彉鐨?     
ASSIGN COMPONENT index OF STRUCTURE itab_out TO <f_fs1>.     <f_fs1> 
= itab_sum-LFIMG.     itab_out
-line_sum = itab_sum-LFIMG.     itab_out
-BRGEW_sum = itab_sum-BRGEW.     
COLLECT itab_out.     
CLEAR itab_out.
ENDLOOP.
ENDFORM" FIXDATA

FORM frm_catlg_set USING p_field p_text  p_key p_edit p_no_out .       gs_fcat


-fieldname   = p_field.       gs_fcat
-reptext     = p_text.       gs_fcat
-key         = p_key.       gs_fcat
-edit        = p_edit.       gs_fcat
-no_out      = p_no_out.       

IF p_field 鈥楲INE_SUM鈥?/span>.           gs_fcat
-emphasize 鈥楥700鈥?/span>.       
ENDIF.
APPEND gs_fcat TO gt_fcat .
CLEAR gs_fcat .
ENDFORM"frm_catlg_set

FORM fieldcat_init .
DATAc(2TYPE n , txt
(20TYPE .
PERFORM frm_catlg_set USING:       

鈥楳ATNR鈥?nbsp;鈥樼墿鏂欑紪鐮佲€?nbsp;鈥榅鈥?nbsp;鈥樷€?nbsp;鈥樷€?nbsp; ,       
鈥楢RKTX鈥?nbsp;鈥樼墿鏂欐弿杩扳€?nbsp;鈥榅鈥?nbsp;鈥樷€?nbsp;鈥樷€?nbsp;,       
鈥榁RKME鈥?nbsp;鈥樺崟浣嶁€?nbsp;    鈥榅鈥?nbsp;鈥樷€?nbsp;鈥樷€?nbsp;.
LOOP AT hs_col .
c + 1.
CONCATENATE 鈥樷€?nbsp;INTO txt.
PERFORM frm_catlg_set USING: txt hs_col-NAME1 鈥樷€?nbsp;鈥樷€?nbsp;鈥樷€?nbsp; .
ENDLOOP.
PERFORM frm_catlg_set USING鈥楲INE_SUM鈥?nbsp;鈥樻暟閲忓悎璁♀€?nbsp;鈥樷€?nbsp;鈥樷€?nbsp;鈥樷€?nbsp;.
PERFORM frm_catlg_set USING鈥楤RGEW_sum鈥?nbsp;鈥樻瘺閲嶁€?nbsp;鈥樷€?nbsp;鈥樷€?nbsp;鈥樷€?nbsp;. gs_layo

-zebra             鈥榅鈥?/span>.

ENDFORM"fieldcat_init

FORM outdata.
PERFORM fieldcat_init .
PERFORM show_alv  TABLES gt_fcat  itab_out[]                      
USING  gs_layo.

ENDFORM" outdata

FORM show_alv TABLES  pt_fcat                       pt_tab               

USING   ps_layout.   gs_grid


-edt_cll_cb 鈥榅鈥?/span>."褰撳睆骞曞け鍘荤劍鐐规椂锛岃嚜鍔ㄥ埛鏂?   gt_event

-name 鈥楥ALLER_EXIT鈥?/span>.   "slis_ev_caller_exit_at_start浜嬩欢   gt_event
-FORM 鈥楩M_BUTTON鈥?/span>.   
APPEND gt_event .   

CALL FUNCTION 鈥楻EUSE_ALV_GRID_DISPLAY_LVC鈥?   
EXPORTING     i_callback_program                  
= sy-repid     i_callback_user_command            
鈥楿SER_COMMAND鈥?     i_grid_settings                    
= gs_grid     i_callback_pf_status_set            
鈥楽ET_PF_STATUS鈥?     is_layout_lvc                       
= gs_layo     it_fieldcat_lvc                     
= pt_fcat[]      it_events                          
= gt_event[]      i_save                             
鈥榅鈥?
*     it_event_exit                     = gt_event_exit[]   
TABLES     t_outtab                            
= pt_tab    
EXCEPTIONS      PROGRAM_ERROR                     
1      
OTHERS                            2     
.
ENDFORM.                    "csalv_set_fcat

FORM user_command USING r_ucomm LIKE sy-ucomm       rs_selfield 
TYPE slis_selfield.   


CASE r_ucomm.     
WHEN 鈥?amp;DATA_SAVE鈥?/span>.     
WHEN 鈥?amp;PRINT鈥?nbsp;OR 鈥?amp;PRT鈥?/span>.           
"PERFORM PRINT.     
WHEN OTHERS.           

LEAVE TO SCREEN 0.   
ENDCASE.

ENDFORM.                    "user_command
*&---------------------------------------------------------------------*
*&      Form  SET_PF_STATUS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->RT_EXTAB   text
*----------------------------------------------------------------------*
FORM set_pf_status USING rt_extab TYPE slis_t_extab..   
SET PF-STATUS 鈥楽TANDARD鈥?/span>.
ENDFORM.                    "SET_PF_STATUS
*&---------------------------------------------------------------------*
*&      Form  fm_button
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->E_GRID     text
*----------------------------------------------------------------------*
FORM fm_button USING e_grid TYPE slis_data_caller_exit.   

CALL FUNCTION 鈥楪ET_GLOBALS_FROM_SLVC_FULLSCR鈥?
*   EXPORTING
*     IR_SALV_FULLSCREEN_ADAPTER       =   
IMPORTING
*     ET_EXCLUDING                     =
*     E_REPID                          =
*     E_CALLBACK_PROGRAM               =
*     E_CALLBACK_ROUTINE               =     e_grid                           
= ref_grid
*     ET_FIELDCAT_LVC                  =
*     ER_TRACE                         =
*     E_FLG_NO_html                    =
*     ES_LAYOUT_KKBLO                  =
*     ES_SEL_HIDE                      =
*     ET_EVENT_EXIT                    =
*     ER_FORM_TOL                      =
*     ER_FORM_EOL                      =     
.

*   CALL METHOD ref_grid->check_changed_data.
* 璁剧疆enter浜嬩欢   
CALL METHOD ref_grid->register_edit_event     
EXPORTING       i_event_id 
= cl_gui_alv_grid=>mc_evt_enter     
EXCEPTIONS       error      
1       
OTHERS     2.   


"CREATE OBJECT gt_event_receiver.   
"SET HANDLER   gt_event_receiver->handle_modify FOR ref_grid.
ENDFORM.                    "FM_BUTTON

以上是关于ABAP 鍐呰〃鐨勮鍒楄浆鎹?鍙戣揣閫氱煡鍗?的主要内容,如果未能解决你的问题,请参考以下文章

Zookeeper Watcher 鏈哄埗 -- 鏁版嵁鍙樻洿閫氱煡 ?

瓒e浘锛氭垜鏄竴涓?HTML 寮€鍙戣€咃紝浣犱滑鐪嬬湅鎴戝仛鐨勮繖涓」鐩拫鏍凤紵

koa,express,node閫氱敤鏂规硶杩炴帴MongoDB

2020-2021骞翠箣闂?65+寮€鍙戣祫婧愭暣鐞?/a>

鎰熻阿浠婂ぉ鑻规灉寮€鍙戣€呭ぇ浼氱粰鐨勭伒鎰燂細绔嬪埢鐩叉娂浠婂勾绗竴涓儹闂ㄨ€冪偣

360楂樼骇鍓嶇鏋舵瀯甯圚ax(璐哄笀淇?锛氬墠绔紑鍙戠紪绋嬭瑷€鐨勮繃鍘汇€佺幇鍦ㄥ拰鏈潵