2017年4月13日 星期四

2017年2月3日 星期五

取得人員兼職職位

 

*&---------------------------------------------------------------------*
*&      Form  GET_POSITION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_LT_PERSON  text
*      -->P_LT_P1001  text
*      -->P_LT_P0000_BEGDA  text
*      -->P_LT_P0000_ENDDA  text
*----------------------------------------------------------------------*
FORM get_position  TABLES   lt_person TYPE hrobject_t
                              lt_p1001 TYPE p1001tab
                    USING   p_begda
                            p_endda.

  CLEAR: lt_p1001, lt_p1001[].
  CALL FUNCTION 'HR_HCP_GET_POSITION_FOR_EMPL'        "人員所屬職位
    EXPORTING
      im_objecttab    = lt_person[]
      im_begda        = p_begda
      im_endda        = p_endda
    IMPORTING
      ex_1001_tab     = lt_p1001[]
    EXCEPTIONS
      read_1001_error = 1
      OTHERS          = 2.

ENDFORM.

取得主管員編

TYPES: objec_t TYPE objec.
Data: lt_result TYPE STANDARD TABLE OF objec_t WITH HEADER LINE,
DATA: lv_leader  TYPE objid.
 
      PERFORM get_manager USING lt_result-objid lw_p0001-begda lw_p0001-endda 
                   CHANGING lv_leader.

*&---------------------------------------------------------------------*
*&      Form  GET_MANAGER
*&---------------------------------------------------------------------*
FORM get_manager USING p_objid p_begda p_endda
                 CHANGING p_manager.

  DATA: lt_manager LIKE TABLE OF objec,
        ls_manager LIKE LINE OF lt_manager.

  CALL FUNCTION 'HRCM_ORGUNIT_MANAGER_GET'
    EXPORTING
      plvar              = '01'
      otype              = 'O'
      objid              = p_objid
      begda              = p_begda
      endda              = p_endda
*     PATH_ID            = ' '
    TABLES
      manager_info_table = lt_manager
    EXCEPTIONS
      path_error         = 1
      root_error         = 2
      nothing_found      = 3
      OTHERS             = 4.
  IF sy-subrc = 0.
    READ TABLE lt_manager INTO ls_manager INDEX 1.
    p_manager = ls_manager-objid.
  ENDIF.

ENDFORM. 


 

取得組織資料

TYPES: objec_t TYPE objec.
data: lv_wegid like T778A-wegid.
data: lt_result TYPE STANDARD TABLE OF objec_t WITH HEADER LINE.
data: l_root   TYPE gdstr.

    PERFORM get_structure TABLES lt_result
      USING sy-datum sy-datum lw_p0001-orgeh lv_wegid l_root.   "組織資料

*&---------------------------------------------------------------------*
*&      Form  GET_STRUCTURE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

*----------------------------------------------------------------------*
FORM get_structure TABLES   lt_result
   USING    p_begda p_endda p_objid p_path l_root LIKE gdstr.

  CLEAR: lt_result, lt_result[], l_root.
  CALL FUNCTION 'HR_STRUCTURE_GET'    "取得組織清單
    EXPORTING
      root_plvar      = '01'
      root_otype      = 'O'
      root_objid      = p_objid
*     ROOT_OBJECTS    =
      begda           = p_begda
      endda           = p_endda
      pathid          = p_path
*     PATHID_IS_INTERN          =
*     STRU_TECH_DEPTH = 0
*     STRU_STATUS_VECTOR        = '1'
*     STRU_STATUS_OVERLAP       = ' '
*     PROVIDE_TEXT    = 'X'
*     PROVIDE_RELAT   = 'X'
*     PROVIDE_DFLAG   = 'X'
*     RECURSION_CHECK = 'X'
*     AUTHORITY_CHECK = 'X'
*     TEXT_BUFFER_FILL          = 'X'
*     READ_MODE       = 'F'
*     KEEP_ORDER      =
    IMPORTING
      result_objects  = lt_result[]
*     RESULT_STRUCTURE          =
      root_copy       = l_root
    EXCEPTIONS
      plvar_not_found = 1
      root_not_found  = 2
      path_not_found  = 3
      internal_error  = 4
      OTHERS          = 5.
  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.
ENDFORM.  

TP_R3_TO_SERVER生成文件放到FTP中.中文亂碼問題

原文:
http://www.itpub.net/thread-1368352-1-1.html

這樣就可以用後台的方式正常往ftp傳輸漢字了。
"把內表數據用此函數SCMS_TEXT_TO_BINARY轉換成2進制;
  然後再FTP_R3_TO_SERVER用這個函數傳ftp 注意用BLOB           = IN_DATA 和  BLOB_LENGTH    = LEN
CALL FUNCTION 'SCMS_TEXT_TO_BINARY'
      IMPORTING
        OUTPUT_LENGTH = LEN
      TABLES
        TEXT_TAB      = CONTENT
        BINARY_TAB    = IN_DATA
      EXCEPTIONS
        FAILED        = 1
        OTHERS        = 2.
    CLEAR CONTENT[].
    REFRESH RESULT.
    CALL FUNCTION 'FTP_COMMAND'
      EXPORTING
        HANDLE        = HDL
        COMMAND       = 'ascii'   "'binary' "
      TABLES
        DATA          = RESULT
      EXCEPTIONS
        TCPIP_ERROR   = 1
        COMMAND_ERROR = 2
        DATA_ERROR    = 3.

    CALL FUNCTION 'FTP_COMMAND'
      EXPORTING
        HANDLE        = HDL
        COMMAND       = 'cr'
      TABLES
        DATA          = RESULT
      EXCEPTIONS
        TCPIP_ERROR   = 1
        COMMAND_ERROR = 2
        DATA_ERROR    = 3.

    CALL FUNCTION 'FTP_R3_TO_SERVER'
      EXPORTING
        HANDLE         = HDL
        FNAME          = FILENAME
        BLOB_LENGTH    = LEN
*        CHARACTER_MODE = 'X'
      TABLES
*        TEXT           = IN_DATA
        BLOB           = IN_DATA
      EXCEPTIONS
        TCPIP_ERROR    = 1
        COMMAND_ERROR  = 2
        DATA_ERROR     = 3.
    IF SY-SUBRC <> 0.
      MESSAGE = '往FTP服務器寫數據失敗。'.
      EXIT.
    ENDIF.
  ENDIF.

2016年8月12日 星期五

CentOS7安裝Cacti

REF:http://www.phpini.com/linux/rhel-centos-7-install-cacti
http://www.tecmint.com/install-cacti-network-monitoring-on-rhel-centos-6-3-5-8-and-fedora-17-12/

yum install httpd httpd-devel
yum install mariadb-server -y       
yum install php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli
yum install php-snmp
yum install net-snmp-utils net-snmp-libs
yum install rrdtool
systemctl start httpd.service
systemctl start mariadb.service
systemctl start snmpd.service
systemctl enable httpd.service
systemctl enable mariadb.service
systemctl enable snmpd.service
yum install epel-release
yum install cacti
mysqladmin -u root password '密碼'       
mysql -u root -p
create database cacti;
GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY '密碼';  //密碼不能包含"\"
FLUSH privileges;
quit;
rpm -ql cacti | grep cacti.sql -> /usr/share/doc/cacti-0.8.8h/cacti.sql
mysql -u cacti -p cacti < /usr/share/doc/cacti-0.8.8h/cacti.sql
vi /etc/cacti/db.php
/* make sure these values reflect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "your-password-here";
$database_port = "3306";
$database_ssl = false;
*/
vi /etc/httpd/conf.d/cacti.conf
/*
Alias /cacti    /usr/share/cacti


# httpd 2.4
Require all granted                //修改


# httpd 2.2
Order deny,allow
Deny from all
Allow from all                    //修改

*/
service httpd restart       
systemctl restart httpd.service
vi /etc/cron.d/cacti
#*/5 * * * *    cacti   /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1    //取消註解

工單建立新增客製欄位

From:
http://www.solutions.sappmconsultant.com/2016/02/pm-order-additional-fields.html#.V6wTmeOx8oA

PM Orders Additional Fields

Here is the perfect document for big question "How to create the additional field on PM order". 

Introduction
One of the very frequently asked questions in this space, is about the subject matter, i.e., How can I add Custom fields to my Maintenance Order? In the recent months the author had replied 3 times to discussions related to this topic. It is thought that this topic if documented would be helping many.
Objective
This documentation is intended to enable the readers to create the Custom fields in the Maintenance Order, update the Order Master data Table and also display these fields in IW38 Order list output.

Part1

Create Custom fields in the Order Table
The table of our context is AUFK. We need to append our Z-fields to this through the include structure namely CI_AUFK.
The process of creating any custom field starts with creating a Data Element with desired Type and Length or with desired Domain name and with the Field Labels we want to have for the Customer fields. For our Demo, we have created Two Data Elements, namely :
1. ZCUSTFLD1 (Domain CHAR12 and Field Label 『Customer Field 1』)
2.ZCUSTFLD2 (Domain CHAR40 and Field Label 『Customer Field 2』)
Now let us create our Customer fields Run Tcode SE11 --> give value AUFK in the Database Table field -->Click on Display. Scroll-down to find include table CI_AUFK. Double click on this, Go to Change mode and Add 2 new fields of our interest as shown in the picture and Activate.

Part2
Enhancement and Screen-Exit

1, Create an Enhancement Project say ZPMORDER using Tcode CMOD
 
 2. Assign Enhancement IWO0018 to this project.

3. Click on Components in the picture above to reach this screen.


4. Activate by clicking on the Activate Icon (shown in picture above)

As we see here, there is One screen-exit (screen 0900) and Two Function-Exits namely EXIT_SAPLCOIH_018 and EXIT_SAPLCOIH_019 in this enhancement. Double Click on this screen number to create a Sub-Screen for holding our Custom Fields. You'll get this pop-up. Press Enter and Continue.

You're in the screen below, where you'll give a Description, Select the Subscreen Radio button, Save and Activate.


Click on Layout Arrow in the Application Toolbar of (See the picture above) to reach the Screen-Painter pop-up window, where we will be creating :
1. A Box to hold our Z-fields
2. Text Fields to for Z-field labels
3. Input Fields for Z-fields


The input fields should be referred to the Dictionary fields we have just created. (AUFK-ZZCUSTFLD1 and AUFK-ZZCUSTFLD2)
See the picture.

Part3

1. Declare table AUFK

Declare table AUFK in the top include LXWOCTOP of Function group XWOC by Clicking on and creating the include ZXWOCTOP .


2. Codes to be given in Function-Exits


Go to the following screen of the User-exit


Double click on the Function-Exit EXIT_SAPLCOIH_018 and put the following code in the include ZXWOCU15.
*---------------------------------------------------------------------------------------------
MOVE-CORRESPONDING COCI_AUFK_IMP TO AUFK.
*---------------------------------------------------------------------------------------------
Similarly put the following code in the include ZXWOCU16  of the Function-Exit EXIT_SAPLCOIH_019.
*---------------------------------------------------------------------------------------------
MOVE-CORRESPONDING AUFK TO COCI_AUFK_EXP.
*---------------------------------------------------------------------------------------------


Now let's see the effect of work done so far.
Create a Maintenance Order (IW31). You will see an Additional Tab named Enhancement has been added here by the system, in which our Custom fields appear with their labels and the input fields.

 Now let's add some values in these fields and Save the Order.

Run IW32, open the Order and verify whether the values are updated to table or not. If they are appearing in the Enhancement tab as you have entered and saved, this means the AUFK table has been updated with these values when Order was saved.

Part4

Let's have these Custom fields in the Order list output namely the ALV of Tcode IW38

So far we have succeeded in creating our Custom fields and updating the values to the Order Master data. Next natural requirement of a user would be to have these fields in IW38 ALV screen. For this purpose we, need to create an Append Structure in the Structure RIHAUFK_LIST, as shown in the picture below. The

Tcode is SE11 again for this task. Here we have created an Append Structure named ZCUSTFLD and in this structure we have added both the Custom fields.

Now let's create one more Order, fill the custom fields with some values and Save. The second order is to have ALV output in IW38. (Because single Order in the output takes to IW33 screen instead of ALV screen). Now run IW38 with selection parameters to display these 2 orders we created. Click on the icon shown , You'd find the Custom fields in the Column-set list, Bring them to Displayed list on the Right hand side.

Almost Done
Now if you go to IW33, unlike all other greyed-out fields, the Custom fields in Enhancement Tab will be seen Editable. Though there is no provision to Save the edits here, you'd definitely like to have these fields too in Greyed-out mode.

For this we need to write a small code in the PBO (Process Before Output) module of the screen 0900 we have created.  Double click on the Screen number 0900 of the enhancement,

Now you are in the Flow Logic Tab ,

Un-comment line MODULE STATUS_900. and D'Click on the STATUS_0900 of the PBO module. Insert the following code between the MODULE, END MODULE lines like this.

-------------------------------------------------------------------------------------
MODULE STATUS_0900 OUTPUT.
     IF SY-TCODE = 'IW33'.
          LOOP AT SCREEN.
               SCREEN-INPUT = '0'.
               MODIFY SCREEN.
          ENDLOOP.
     ENDIF.
ENDMODULE.
-------------------------------------------------------------------------------------

Lastly Do not Forget to

Activate the Function Group XWOC from Tcode SE80. Right click on the Function Group and click on the Activate option
Note
1. As this is largely a Technical job, it is recommended to be developed through an experienced ABAPer, especially Part1 which involves Activating the Standard table AUFK.

2. The Environment of Author is ECC 6.0 with no EHPs, hence the document applicability.
Thanks for this documents to Jogeswararao Kavala
Source: http://scn.sap.com/docs/DOC-54402