2010-08-12

How To : E-PB: How To Get Verity for PeopleTools 8.50

E-PB: How To Get Verity for PeopleTools 8.50 [ID 949230.1]


In version 8.50, Verity is not included within PeopleTools' package. PeopleSoft PeopleTools and PeopleBooks use Verity to implement the application's inner searching.

Install Verity after installing PeopleTools, and before the database is created.  Install Verity on all of the machines where the Application Server, Batch Server, and the Web Server have been setup.

Download Verity for PT 8.50  “PeopleSoft Enterprise PeopleTools 8.50 Verity” from Oracle’s e-delivery at http://edelivery.oracle.com

Or
Download it from the PeopleSoft FTP site at ftp://ftp.peoplesoft.com/outgoing/ptools/verity/ver621/

And

Please refer to the “Task 4-4: Installing the Verity Integration Kit” in PeopleTools_8.50_installation_Oracle.pdf.

Download the "PeopleTools_8.50_installation_Oracle.pdf." from the http://edelivery.oracle.com site.




When installing, use install keys from here:
The install document you will be using is PeopleTools_8.50_Installation_Oracle.pdf.  It gives excellent step-by-step instructions on everything you need to do to install PeopleTools as well as the HRMS application.  It is somewhat of a generic document, meant for PeopleTools as well as many other applications you might want to install.  HRMS is only one of the applications it talks about.
Download the PDF from the Oracle EDelivery site.  When you see that it is a 700 page install document, you’ll realize what you’ve gotten yourself into.  You will have to go through most of it.
Ok, now here’s a high-level summary of suggested steps :
  1. Install Oracle database
  2. Install PeopleTools CD
  3. Install Application CD (i.e. HRMS & Campus Solutions. Make sure that install HRMS & Campus Solutions into the same folder as PeopleTools.)
  4. Create Oracle DB for PeopleSoft
  5. Install BEA Tuxedo CD
  6. Install BEA Weblogic CD
  7. Configure App Server
  8. Install and Configure PIA
  9. Login to PIA

2010-07-26

Filelayout - ReadRowset Example

[From Peoplebook http://download.oracle.com/docs/cd/E15645_01/pt850pbr0/eng/psbooks/tpcr/book.htm?File=tpcr/htm/tpcr19.htm%23g037ee99c9453fb39_ef90c_10c791ddc07__1429]

ReadRowset Example


The following program reads all the rowsets from a file and updates a work scroll with that data. The work scroll isn’t hidden on the page: it’s created in the Component buffer from existing records using CreateRowset. The structure of the work scroll and the file layout are identical: that is, they’re composed of two records, and the names of the records in the file layout are exactly the same as the names of the record definitions.

Local File &CHARTINPUT_F; Local Rowset &INPUT_ROWSET, &TEMP_RS, &WORK_DATA; Local Record &WRK_DATA; &filename = "c:\temp\test.txt"; If FileExists(&filename, %FilePath_Absolute) Then &CHARTINPUT_F = GetFile(&filename, "R", "A", %FilePath_Absolute); Else Exit; End-If; &CHARTINPUT_F.SetFileLayout(FileLayout.CHART_INFO); /* Create rowset to be read into NOTE that you have to start at LOWEST level of rowset */ &TEMP_RS = CreateRowset(RECORD.CHART_ITEM); &WORK_DATA = CreateRowset(RECORD.CHART_DATA, &TEMP_RS); &INPUT_ROWSET = CreateRowset(RECORD.CHART, &WORK_DATA); While &INPUT_ROWSET <> Null &INPUT_ROWSET = &CHARTINPUT_F.ReadRowset(); &INPUT_ROWSET.CopyTo(&WORK_DATA); /* do processing -- Though file may contain more than one level zero Component processor only allows one level zero at a time */ End-While;

2010-07-14

Refreshing Security Join Tables

To refresh security join tables, use the Nightly SJT Refresh Process component (SCRTY_SJTDLY_RC), Refresh Trans. SJT tables component (SCRTY_SJT_RC), the Refresh SJT_CLASS_ALL component (SCRTY_OPR_RC), and the Refresh SJT_OPR_CLS component (SCRTY_OPRCLS_RC).

PeopleBook (PeopleSoft Enterprise HRMS 9.1 Application Fundamentals PeopleBook > Setting Up and Administering HRMS Security) describes when to use the refresh processes and discusses how to:

* Run the nightly refresh process.
* Run the transaction security join table refresh process.
* Run the Refresh SJT_CLASS_ALL process.
* Run the Refresh SJT_OPR_CLS process.

2010-07-06

PS_PTLT_COMP_NAV

http://evmultimedia.ro/peoplenet/?p=334

PS_PTLT_COMP_NAV – Define Components Navigation Setup record (in PT>=8.4xx). It is a very useful table especially when you are given a certain PeopleSoft link or Component and you don’t know how to identify the navigation path. The record stores the PTLT_TASK_CODE which is the component name followed by the market name “.GBL”/Global extension, the PTLT_FEATURES_LIST which represents the general features that the component/page encloses (eg: for the component -BUS_UNIT_TBL_BI.GBL – Set Up Financials/Supply Chain > Business Unit Related > Billing > Billing Definition the enclosed features are “”BI Business Unit Billing General Promotions Management General” ), the product code lists (PTLT_PROD_CD_LIST) which stores a list of relevant module/functional abreviations for the specific component (eg:AM,BI,AR,etc – Asset Management,BI – Business Intelligence, AR – Accounts Receivable), and finally the Navigation path to the current page (NAVIGATION) (eg: for USERMAINT.GBL – Navigation field is PeopleTools > Security > User Profiles > User Profiles). If the component has no corresponding Portal Navigation path the field stores “No Portal Navigation Available”.

To determine the path to a certain component in PeopleSoft one can issue the following SQL statement:

SELECT NAVIGATION FROM PS_PTLT_COMP_NAV WHERE PTLT_TASK_CODE=’COMPONENT_NAME.GBL’

To determine the type of access,components/menus and navigation paths on which a permission list grants rights one can run the following query:

select DISTINCT N.NAVIGATION , N.PTLT_TASK_CODE COMPONENT,b.menuname MENU, a.CLASSID PERMISSION_LIST,
DECODE(a.DISPLAYONLY,1,’TRUE’,0,’FALSE’) DISPLAYONLY,
(CASE
WHEN a.AUTHORIZEDACTIONS=1 THEN ‘ADD’
WHEN a.AUTHORIZEDACTIONS=2 THEN ‘UPDATE,DISPLAY’
WHEN a.AUTHORIZEDACTIONS=3 THEN ‘ADD,UPDATE, DISPLAY’
WHEN a.AUTHORIZEDACTIONS=4 THEN ‘UPDATE/DISPLAY ONLY’
WHEN a.AUTHORIZEDACTIONS=5 THEN ‘ADD,UPDATE/DISPLAY ALL’
WHEN a.AUTHORIZEDACTIONS=6 THEN ‘UPDATE,DISPLAY,UPDATE/DISPLAY ALL’
WHEN a.AUTHORIZEDACTIONS=7 THEN ‘ADD,UPDATE,DISPLAY,UPDATE/DISPLAY ALL’
WHEN a.AUTHORIZEDACTIONS=8 THEN ‘CORRECTION’
WHEN a.AUTHORIZEDACTIONS=9 THEN ‘ADD,CORRECTION’
WHEN a.AUTHORIZEDACTIONS=10 THEN ‘UPDATE,DISPLAY,CORRECTION’
WHEN a.AUTHORIZEDACTIONS=11 THEN ‘ADD, UPDATE/DISPLAY ALL, CORRECTION’
WHEN a.AUTHORIZEDACTIONS=12 THEN ‘UPDATE/DISPLAY ALL,CORRECTION’
WHEN a.AUTHORIZEDACTIONS=13 THEN ‘ADD, UPDATE, DISPLAY,UPDATE/DISPLAY ALL,CORRECTION’
WHEN a.AUTHORIZEDACTIONS=14 THEN ‘UPDATE,DISPLAY,UPDATE/DISPLAY ALL,CORRECTION’
WHEN a.AUTHORIZEDACTIONS=15 THEN ‘ADD,UPDATE,DISPLAY,UPDATE/DISPLAY ALL,CORRECTION’
WHEN a.AUTHORIZEDACTIONS=128 THEN ‘DATA ENTRY’
ELSE ‘UNKNOWN’
END ) AUTHORIZEDACTIONS
FROM PS_PTLT_COMP_NAV N
inner join PSMENUITEM b ON N.PTLT_TASK_CODE=b.PNLGRPNAME ||’.GBL’
inner join PSAUTHITEM a ON a.menuname = b.menuname AND a.baritemname = b.itemname
where a.CLASSID=’YourPermissionList’

2010-06-24

SendMail PeopleCode function

You can use the SendMail PeopleCode function to send emails from within PeopleCode. You can also call this function from an Application Engine.

Note: Make sure your SMTP server is configured properly or the SendMail function will fail.

--------------------------------------------------------------------------
Local string &MAIL_CC, &MAIL_TO, &MAIL_BCC, &MAIL_SUBJECT, &MAIL_TITLES, &MAIL_TEXT, &MAIL_FILES, &MAIL_FROM, &REPLYTO, &SENDER;
Local number &MAIL_FLAGS;

&MAIL_FLAGS = 0;
&MAIL_TO = "email-address-message-going-to";
&MAIL_CC = "";
&MAIL_BCC = "";
&MAIL_SUBJECT = "Test email";
&MAIL_TEXT = "Sending an email from PeopleCode.";
&MAIL_FILES = "";
&MAIL_TITLES = "";
&MAIL_FROM = "email-address-message-is-from";
&MAIL_SEP = ";";
&CONTTYPE = "";
&REPLYTO = "";
&SENDER = "";

&RET = SendMail(&MAIL_FLAGS, &MAIL_TO, &MAIL_CC, &MAIL_BCC, &MAIL_SUBJECT, &MAIL_TEXT, &MAIL_FILES, &MAIL_TITLES, &MAIL_FROM, &MAIL_SEP, &CONTTYPE, &REPLYTO, &SENDER);

If &RET <> 0 Then
MessageBox(0, "", 0, 0, "Return code from SendMail= " | &RET);
/*Do error processing here*/
End-If;
--------------------------------------------------------------------------



Your PeopleCode will have an SQLExec function to get the OPERATOR's email address.

--------------------------------------------------------------------------
SELECT emailid
FROM psoprdefn
WHERE oprid = (SELECT supervisor_id
FROM ps_employees
WHERE emplid = 'user-id-submitting-request');
--------------------------------------------------------------------------

2010-06-09

Scheduled PSJob distribution list

When you want to detect the distribution list within a scheduled job, the two tables will be fancy to see:

select * from PS_SCHDLITEM -- All scheduled items
select * from PS_SCHDLRPTDIST -- All distribution list

2010-06-08

PeopleSoft Batch Server

PeopleSoft Batch Server
From [http://visualsuccess.com/mediawiki/index.php/PeopleSoft_Batch_Server]


The Peoplesoft Batch Server, generally known as the PeopleSoft Process Scheduler, polls the database (PSPRCSRQST table) at regular intervals (intervals defined as Heartbeat and Sleep Intervals) performs maintenance (like determining if it is supposed to shutdown) and polls for actionable process requests (example: run Application Engine Programs, Cobol Programs, SQR’s, or other batch proccesses). The PeopleSoft Process Scheduler Server (also known as Process Scheduler Agent) can be managed using the PSADMIN command located in the PS_HOME/APPSERV directory. The Process scheduler agent is responsible for initiating most batch and report processes in PeopleTools. Process Scheduler tables can grow quickly – affecting system performance and space, it is important to purge them on a regular basis; use delivered PRCSPURG.sqr or the new PSTools 8.4+ app engine program PRCSYSPURGE. The process scheduler is configured (including trace file location) using the psprcss.cfg and psprcsssrv.* files (typically located %PS_HOME%\\appserv\prcs\. Peoplesoft 8.4+ added a master process scheduler which acts as a load balancer for other process schedulers.
Key Tables

* PSPRCSRQST Process Request table; Process Scheduler executes and updates with status information. Key field RUNSTATUS 1=cancel; 2=delete; 3=error; 4=hold; 5=queued; 6=initiated; 7=processing; 8=cancelled; 9=success; 10=notSuccess; 11=posted; 12=unableToPost; 13=resend; 14=posting; 15=content generated; 16=pending; 17=successWarning; 18=blocked; 19=restart
* PS_PRCSSEQUENCE Process Sequence Number
* PS_PRCSRUNCNTLDTL Destination Options
* PS_BATRUNCNTL Process Specific Run Control
* PS_PRCSRQSTDIST Distribution Requests
* PSPRCSPARMS Process Request Parameters
** PS_PMN_PRCSLIST Process Monitor list (five stars!)

Troubleshooting Peoplesoft Batch Server

* Poor Performance - (1) Navigate to PeopleTools/ Process Scheduler Manager/ Servers/ Server Definition; consider increasing Sleep Time and Heartbeat Time – this will increase request start time but decrease database load. (2) Consider changing process definition to restrict number of processes allowed to run concurrently; or add to Server Definition a new Process Type that limits max concurrent runs, or add a maximum processing time to the process definition. (3) Consider (on operating system) lowering or raising process scheduler priority

2010-06-03

After being a deadlock victim, rerun VAT1001 SQR report

User just suffered from a pain:
"Transaction (Process ID 93) was deadlocked on lock resources with another process and has been chosen as the deadlock victim".
Simply re-issuing the report will cause another problem - in VAT1001 SQR Report (even Process Monitor showed "Success" and "Posted"), it just shows:
PROCESS_INSTANCE = 123456789
No rows found to round in PS_VAT_TXN_TMP_TBL
----------------------------------------------------------------------------------------------------------

Oracle Metalink has an article explains how to run the VAT report, which is:
EGL: How to Set Up And Run a VAT Report ? [ID 620419.1]

However, from VAT1001.SQR, we can see more:

begin-procedure Main-Processing
    #debugp do Debug-Msg('Main-Processing')

    do Mark-Txn-Lines
    do Insert-vat-txn-tmp-tbl
    #ifdef MICROSOFT
       do Update-Statistics
    #else
       #ifdef INFORMIX
         do Update-Statistics
       #else
          #ifdef ORACLE
             do Update-Statistics
          #end-if
       #end-if
    #end-if
    do delete-frm-vat-txn-tbl
    do Fill-Line-Info
    do Get-Report-Defn-Header
    do Get-Home-Country
    do Create-VAT-Rpt-Inst1
    do Process-Report-Lines
    do Insert-vat-rpt-err1
    do Check-for-Unselected
    do Update-In-Process-Flag
    do insert-vat-txn-tbl
    do delete-vat-txn-tmp-tbl
    do Process-Scheduler-Closing

    #debugp display 'Leaving Main-Processing'
end-procedure ! Main-Processing


In the process Mark-Txn-Lines, we can see, the SQR marks the lines by some criteria, but here I just want to point out 3 conditions for the lines being reported:
  • In table PS_VAT_TXN_TBL, field IN_PROCESS_FLG is set as 'N';
  • No result should be found by the SQL, if found, delete the lines having PROCESS_INSTANCE = [## the failed PI##] the from table PS_VAT_RPT_INST2; or, change their PROCESS_INSTANCE to a easy number to trace back (say, -1122334455?) :

SELECT * FROM PS_VAT_TXN_TBL, PS_VAT_RPT_INST2 B, PS_VAT_RPT_INST1 C
  WHERE  PS_VAT_TXN_TBL.PROCESS_INSTANCE = [## the failed PI##]
  AND B.PROCESS_INSTANCE = C.PROCESS_INSTANCE
  AND B.VAT_RPT_ID = C.VAT_RPT_ID
  AND PS_VAT_TXN_TBL.VAT_ENTITY = B.VAT_ENTITY
  AND PS_VAT_TXN_TBL.COUNTRY_VAT_RPTG = B.COUNTRY_VAT_RPTG
  AND PS_VAT_TXN_TBL.VAT_DCMNT_ID = B.VAT_DCMNT_ID
  AND PS_VAT_TXN_TBL.LINE_NBR = B.LINE_NBR
  --AND C2.VAT_RPT_TYPE = $rqst_vat_rpt_type;
  • Cross your finger to wish NO result be found by the SQL below (otherwise, you need to check what caused a previous reporting error - check PeopleBooks???):

SELECT * FROM PS_VAT_TXN_TBL, PS_VAT_RPT_ERR2 B2, PS_VAT_RPT_INST1 C2
  WHERE B2.PROCESS_INSTANCE = C2.PROCESS_INSTANCE
  AND PS_VAT_TXN_TBL.VAT_ENTITY = B2.VAT_ENTITY
  AND PS_VAT_TXN_TBL.COUNTRY_VAT_RPTG = B2.COUNTRY_VAT_RPTG
  AND PS_VAT_TXN_TBL.VAT_DCMNT_ID = B2.VAT_DCMNT_ID
  AND PS_VAT_TXN_TBL.LINE_NBR = B2.LINE_NBR
  --AND C2.VAT_RPT_TYPE = $rqst_vat_rpt_type
  AND B2.VAT_RPT_ASSOC_FLG IN ('T', 'A')   

Then re-run VAT1001.

2010-05-31

PSAUTHITEM.AUTHORIZEDACTIONS Codes indicating the Authorized Actions

In Table PSAUTHITEM

AUTHORIZEDACTIONS Codes : the Authorized Actions
1: Add
2: Update Display
3: Add/Update/Display
4: Update/Display All
5: Add/Update/Display All
6: Update/Display/Update/Display All
7: Add/Update/Display/Update/Display All
8: Correction
9: Add/Correction
10: Update/Display / Correction
11: Add/Update/Display/Correction
12: Update/Display All/Correction
13: Add/Update/Display All/Correction
14: Update/Display/Update/Display All/Correction
15: Add/Update/Display/Update/Display All/Correction
128: Data Entry

For all the authorized actions for a given menu item for a given operator, these numbers are added together and stored in the authorizedactions column.

For example, if the value for authorizedactions column is 143, the operator is authorized for all the actions. (1+2+4+8+128) .

As another example, if the value is 7, the operator is authorized for the actions Add, Update/Display, Update/Display All (1+2+4).

2010-05-26

Howto get the names of ROLE with a specified Permission List

It will be a very boring work if you want to search for the Roles one by one to see which role has the Permission List wanted.

SQL helps:
select ROLENAME from PSROLECLASS where CLASSID='[the_permission_list]';
Then we can grant user the role from the result.
insert into PSROLEUSER values ('[user_id]', '[role_name]', '[dynamic_sw]')
======== To overview all permission lists assigned to a USER. ========

select RU.ROLEUSER, RU.ROLENAME, RC.CLASSID from PSROLEUSER RU, PSROLECLASS RC where RU.ROLENAME=RC.ROLENAME and RU.ROLEUSER='PS'

Monitoring Integration Broker Messages

To monitor these PUB messages, we can have a look in the tables below:

  • PSAPMSGPUBCON
  • PSAPMSGSUBCON
  • PSIBLOGHDR
  • PSAPMSGPUBHDR

The SQLs I am using to detect failed messages are:

select * from PSAPMSGPUBCON where STATUSSTRING='ERROR'
or, if want to see more:
select * from PSAPMSGPUBHDR HDR, PSAPMSGPUBCON CON where HDR.IBTRANSACTIONID=CON.IBPUBTRANSACTID and CON.STATUSSTRING not in ('DONE', 'CNCLD')

The STATUSSTRING can be replaced by PUBSTATUS, with its Status Codes:
0 - Error, 1 - New , 2 - Started, 3 - Working,
4 - Done, 5 - Retry, 6 - Timeout, 7 - Edited, 8 - Canceled


I believe it is not hard at all to jump from PUB messages to SUB messages. :)

2010-05-19

PeopleSoft Meta-Tables

[original: http://www.compshack.com/wiki/peoplesoft/peopletools/peoplesoft-peopletools-meta-tables]

This is an attempt to list PeopleSoft meta-tables along with some kind of description for every table. The list will be broken into categories (pages, records, components, and so forth). Please feel free to add to or correct the list, this is a wiki page, so jump in!

PeopleSoft Projects

PSPROJECTDEFN table stores information about projects created in Application Designer.
Try it out:

SELECT * FROM PSPROJECTDEFN
WHERE PROJECTNAME = 'Your_Project_name';
PSPROJECTITEM table stores objects inserted into your Application Designer project.
Try it out:

SELECT * FROM PSPROJECTITEM
WHERE PROJECTNAME = 'Your_Project_name';

Portal Structure

PSPRSMDEFN is a Portal Structure Definition table. A good example is to use this table to find portal path for a specific component. Take a closer look on how this is done!.
PSPRSMPERM: Shows the permission lists that are assigned to a portal registry structure (content reference). The permission list name is under field PORTAL_PERMNAME.

XLAT Tables

XLATTABLE: Stores translate values (PeopleSoft version prior to 8.4).
PSXLATDEFN: Stores all fields that have Xlat values. This table does not store any Xlat values.
PSXLATITEM: Stores fields with their actual translate values (PeopleSoft version 8.4 and above).

Record & Field Tables

PSRECDEFN: Stores informations about tables. One row for each table. Field count and record type are two fields that are stored on this table.

CASE RECTYPE
        WHEN 0 THEN 'Table'
        WHEN 1 THEN 'View'
        WHEN 2 THEN 'Derived'
        WHEN 3 THEN 'Sub Record'
        WHEN 5 THEN 'Dynamic View'
        WHEN 6 THEN 'Query View'
        WHEN 7 THEN 'Temporary Table'
        ELSE TO_CHAR(RECTYPE)
END CASE
PSRECFIELD: Stores records with all their fields (sub-records are not expanded)
PSRECFIELDALL: Stores records with all their fields (sub-records are expanded)
PSINDEXDEFN: Contains 1 row per index defined for a table.
PSKEYDEFN: Containes 1 row per key field defined for an index.
PSDBFIELD: You got it, stores information about fields.

CASE FIELDTYPE
                WHEN 0 THEN 'Character'
                WHEN 1 THEN 'Long Character'
                WHEN 2 THEN 'Number'
                WHEN 3 THEN 'Signed Number'
                WHEN 4 THEN 'Date'
                WHEN 5 THEN 'Time'
                WHEN 6 THEN 'DateTime'
                WHEN 8 THEN 'Image'
                WHEN 9 THEN 'Image Reference'
                ELSE TO_CHAR(FIELDTYPE)
        END CASE
PSDBFLDLABL: Stores field label information.

Process Definition Table(s)

PS_PRCSDEFNPNL: Stores the process definition name, process type(sqr report, application engine...), and the component name associated with the process definition.
PS_PRCSDEFN: Process definitions table. The record stores processes that can run within the Process Scheduler. Security information such as components and process groups are also stored on this table.

Message Catalog Tables

PSMSGCATDEFN: Stores information about PeopleSoft message catalogs such as message set number, message number and the actual message text.
PSMSGCATLANG: language table.

-- Example
SELECT * FROM PSMSGCATDEFN
WHERE LAST_UPDATE_DTTM  > TO_DATE('03-DEC-07', 'DD-MON-YY')
AND LAST_UPDATE_DTTM  < TO_DATE('05-DEC-07', 'DD-MON-YY')
ORDER BY MESSAGE_SET_NBR, MESSAGE_NBR;
-- This will return messages that has been last update/added between 2 specific dates.

Previous PeopleSoft message catalog tables:
PS_MESSAGE_CATALOG: Stores information about PeopleSoft message catalogs such as message set number, message number and the actual message text.
MESSAGE_SET_TBL: Message set description table.
-- Example
SELECT * FROM PS_MESSAGE_CATALOG
WHERE LAST_UPDATE_DTTM  > TO_DATE('03-DEC-07', 'DD-MON-YY')
AND LAST_UPDATE_DTTM  < TO_DATE('05-DEC-07', 'DD-MON-YY')
ORDER BY MESSAGE_SET_NBR, MESSAGE_NBR;
-- This will return messages that has been last update/added between 2 specific dates.

Menu Tables

PSMENUDEFN: Store Menu related information. No related component info on this table.
PSMENUITEM: List the menu with all components attached to it.

Component Tables

PSPNLGRPDEFN: Stores component related information only.
PSPNLGROUP: This table will give you information regarding a specific component along with the names of pages attached to it.

Pages

PSPNLDEFN: Stores pages definitions.
PSPNLFIELD: Stores all items used by each page definition.

Security

PSPRSMPERM: Portal Structure Permissions.
PSAUTHITEM: Page Permissions. This table stores the information about the page level access for a permission list.
PSROLECLASS: Role Classes table. A many to many relationship table between Roles and Permission Lists.
PSROLEDEFN: This table stores information about Peoplesoft Role definitions. Users get permissions to PeopleSoft objects through Roles, which are assigned Permission Lists.
PSROLEUSER: This table stores information about the Users in Peoplesoft and the roles assigned to them.
PSCLASSDEFN: Permissions List definitions table. Permission list name can be found under Field Name CLASSID.
PSOPRDEFN: Users/Operator definition table. This table stores information about PeopleSoft users. This is the core table for User Profile Manager.
PSOPRCLS: Users/Operator and Perm list mapping Table. This table stores information about PeopleSoft users and the permission lists attached to those users.
A User gets these permission lists indirectly through the roles which are attached to the user
Here is an example query post that uses all of the above security tables!

URL Definitions

PSURLDEFN: Stores URL definitions. Here is the path to create URL definitions in PeopleSoft Root >> PeopleTools >> Utilities >> Administration >> URLs

Application Classes

PSAPPCLASSDEFN: Application Class Definitions table. You can use field PACKAGEROOT to search for a specific Application Package.

PeopleSoft Query Tables

PSQRYDEFN: Stores query related info.
PSQRYFIELD: Stores all fields used in a query (both the fields in the Select and Where clause).
PSQRYCRITERIA: Stores criteria query fields. You can get the name of the fields by joining the PSQRYFIELD table.
PSQRYEXPR: Stores query expressions.
PSQRYBIND: Stores query bind variables.
PSQRYRECORD: Stores all records used in all aspects of query creation
PSQRYSELECT: Stores all SELECT requirements by select type. Example would be sub select, join, ect.
PSQRYLINK: Stores the relationships to child queries.
PSQRYEXECLOG: Query run time log table that stores (only 8.4x and higher)
PSQRYSTATS: Query run time statistics table such as count of query execution, and date time of last execution (only in 8.4x and higher).

SQL Objects

PSSQLDEFN: Stores SQL object definitions.
PSSQLDESCR: Stores SQL objects descriptions, and description long.
PSSQLTEXTDEFN: Stores actual SQL text. You can filter by SQLTYPE field to get SQL objects of interest such as Views SQLs and Application Engine SQLs.

-- When SQL type is:
0 = Stand alone SQL objects
1 = Application engine SQL
2 = Views SQLs

Application Engines

PSAEAPPLDEFN: Table that stores Application Engine program definitions.
PSAEAPPLSTATE: Stores application engine STATE records and a flag to indicate if the record is the default STATE record.
PSAESECTDEFN: Application engine section information and also stores last user id to update a specific section.
PSAESECTDTLDEFN: AE section along with descriptions and wither the section is active or not.
PSAEAPPLTEMPTBL: If your application engine uses Temp tables it will show on this record.
PSAESTEPDEFN: Steps in application engines are stored in this table.
PSAESTMTDEFN: Stores your application engine actions and along with their types, such as "Do Select" and so on.
PSAESTEPMSGDEFN: Application engine message action definition table.
AEREQUESTTBL: Application Engine request table behind the AE run control page.
AEREQUESTPARM: Application Engine request parameters table behind the AE run control page.

PeopleCode Tables

PSPCMNAME: PeopleCode Reference table.
PSPCMPROG: Store actual PeopleCode programs (actual code behind PeopleCode events).

Process Request Tables

PSPRCSQUE: This record contains the process request information to run a process request.
PSPRCSRQST: This record contains the process request information to run a process request.
PS_PMN_PRCSLIST: A view to list all process requests in the Process Monitor except for "Delete" (runstatus = 2) process requests.

Other Useful Tables

PSSTATUS: Stores PeopleSoft information such as PS Tools release version and the UNICODE_ENABLED boolean flag where a value of 1 indicates the DB is to be treated by Tools as a UNICODE DB.
PSCHGCTLLOCK: Description as explained by PeopleSoft "This table contains a a row for every object that is currently locked by any user. When the user requests to lock an object in the Application Designer, first this table is searched to see if the object is locked by another user. If it is not found, a row is inserted into the table. When the user requests to unlock an object, the row in this table is deleted."
Visit this post to see how could you make use of this table.
PSMAPFIELD: Stores Field mapping of Activity
PS_PRCSRUNCNTL: Run Control record stores Run Control IDs created online.

2010-05-12

HRMS Security Update


 In order to apply security settings for newly created account, run the following three AE's -

SCRTY_CLSUPD - Refresh SJT_CLASS_ALL
SCRTY_OPRCLS
SCRTY_SJTUPD
We created a job which runs the following nightly. It is my
understanding that they need to run in this sequence.



Since these deal with row-level security, and since they rebuild the SJT
tables, if they are run while people are on the system, those people
will temporarily lose their ability to look at employees.
----------------- more -----------
HR_PERSDATA Application Engine - Updates the PERSONAL_DATA snapshot table with future dated entries as they become effective.

NAME_DISPLAY Application Engine - Refreshes the NAME_DISPLAY and NAME_FORMAL fields in all records with the NAME_GBL_SBR. Use when the criteria used to change these fields is changed.

PER099 Application Engine - Fill EMPLOYEES Table.

PTAF_NEM Application Engine - PTAF_NEM - Approval Framework Escalation App Engine.           AWE Workflow escalation process.

SCRTY_OPRCLS Application Engine - SCRTY_OPRCLS - Updates the SJT_OPR_CLS security Join Table.

SCRTY_SJTDLY Application Engine -  Nightly update for SJT Records -  Update of all effdt rows that have become current as of this data.

HRS_AM Application Engine - Applicant Search Auto-Match -Recruiter Applicant Search auto-match process.

HRS_DUPE_PRC Application Engine - Find Applicant Duplicates - Finds applicant duplicates given certain criteria.

HRS_JOB_AGNT Application Engine - Job Agent - Run the Job Posting Search Agent process.

HRS_JSCH_IDX Application Engine -Verity based Job Posting Index build process.

HRS035 SQR Report - Application Analysis (USA).

PER506 SQR Report - Department Tbl & Departmental - This report lists any departments that you have created in the Department Tree but have not yet added to the departmental security tree, It also lists any changes in departments since the effective date of the current security tree.

PER900 SQR Report - Core HR Data Integrity Audit. - Audit of the CORE HR Tables for Data Relationship Integrity.

PSBARUN - Cobal Job - For the Benefit Administration - scheduled to run twice each night with some custom pre and post processes.

Troubleshooting PT 8.48 PT 8.49 Integration Broker

http://iambic.homeip.net/site/doku.php/tech/psoft/ib_troubleshooting
====== Troubleshooting PT 8.48 PT 8.49 Integration Broker ======
Troubleshooting guidance for publication process, subscription process, and other possible problems.

===== Publication Process Problems =====
 Possible publication process problems include:\\
  * Publication contract is not created.
  * Publication contract is in NEW status.
  * Publication contract stays in RETRY status.
  * Publication contract is in WORKING status.
  * Publication contract is in TIMEOUT status.
  * Publication contract is in ERROR status.

==== Pub Contract Is Not Created ====
  * No publication PeopleCode exists.
  * Publication PeopleCode is incorrect.
  * No outbound routings exists for the service operation.

==== Pub Contract Is in NEW Status ====
  * Sending queue is paused.
  * Publication Dispatcher crashed or was brought down.
  * Sending node is paused.
  * Previous service operation had a status of Retry, Error, or Timeout.
  * Sending domain is not active.
  * After an unsuccessful ping, a row may be added to the table PSNODESDOWN; which will hold up the message queue; query the table PSNODESDOWN.

==== Pub Contract Stays in RETRY Status ====
  * The remote node cannot be pinged successfully; the publication contract will be processed when the remote node comes back up.
  * No publication handler is available, either because it crashed or it was brought down.
  * Receiving Node URL is incorrect in integrationGateway.properties file.

==== Pub Contract Is in WORKING Status ====
  * The publication handler processing the contract is on another machine and either the machine or the domain is down. Processing should continue when the pub/sub system on the other machine comes back up.
  * Single threading on the application server is slowing processing.

==== Pub Contract Is in TIMEOUT Status ====
  * An exception occurred on the target application server (look in APPSRV.LOG file for details); verify that:
  * The reply is incorrectly routed; check Gateway for correct machine address of target node.
  * Bad XML syntax.

==== Pub Contract Is in ERROR Status ====
  * Receiving node user profile not authorized to service operation.
  * Inbound routing is not set up on the receiving system.
  * Service operation is not active on the receiving system.
  * Service operation has not been granted security access on the receiving system.
  * The source node is not defined in the target database.
  * Handler PeopleCode is bad.
  * Remote application server is down.
  * Receiving Node is not defined in the integrationGateway.properties file.
  * Receiving PeopleSoft node has not been added to single signon.
  * Service operation version on target is not active.

===== Subscription Process Problems =====

Possible subscription process problems include:\\
  * Subscription contract is not created.
  * Subscription contract is in NEW status.
  * Subscription contract is in STARTED status.
  * Subscription contract is in WORKING status.
  * Subscription contract is in ERROR status.
  * Subscription contract is in EDIT status.

==== Sub Contract Is not Created ====
  * No handler exists for the service operation.
  * Service operation handler is missing method.
  * Queue routing rules not set up properly.

==== Sub Contract Is in NEW Status ====
  * Application Server down.
  * Pub/Sub processes not configured on Application Server domain.
  * The Subscription Dispatcher has crashed or has been brought down.
  * Receiving queue is paused.
  * Receiving node is paused.
  * Previous service operation had errors or timed out.
  * No row was inserted into PSAPMSGSUBPRCID, To insert a row enter the following SQL statement in your Query tool use the following statement:
insert into PSAPMSGSUBPRCID values(0)

==== Sub Contract Is in STARTED Status ====
  * Subscription Handler is down.
  * Target component is not valid.

==== Sub Contract Is in WORKING Status ====
  * Subscription Handler crashed while processing message.

==== Sub Contract Is in ERROR Status ====
  * Queue property if Ordered enables subscription contracts to go in random order, which causes FULLSYNC service operations to error out  when the transaction is subscribed before the header.
  * Service operation handler PeopleCode errors exist.
  * Application data errors exist.

==== Sub Contract Is in EDIT Status ====
Possible cause is that the XML was edited and is not yet resubmitted for processing.

===== Other Possible Problems =====
Other possible problems include:\\
  * Cannot find service operation in Service Operation Monitor.
  * Service operations are being processed in an incorrect order.
  * Service operation is not created.
  * Service operation instance stays in NEW status.
  * Service operation instance stays in STARTED status.
  * Service operation instance stays in WORKING status.
  * Unable to ping a node.
  * Queue is PAUSED.

==== Cannot Find Service Operation in Service Operation Monitor ====
  * Possible causes is that filtering is set in the Service Operation Monitor.

==== Service Operations are Being Processed in an Incorrect Order ====
  * Possible cause is that the queue was partitioned and the resulting subqueues do not match what was assumed for the ordering of the service operations.

==== Service Operation Instance not Created ====
  * Possible cause is that the service operation is inactive.

==== Service Operation Instance Stays in NEW Status ====
  * The Application server is down.
  * Pub/sub services are not configured on the Application Server domain.
  * The Message Dispatcher crashed or was brought down.
  * The item is not at the top of the queue; all service operations with the same queue or subqueue are in the same queue.

==== Service Operation Instance Stays in STARTED Status ====
  *  All Message Handlers crashed or were brought down; processing will resume when Message Handlers come back up.
  * The Message dispatcher processing the message is on another machine, and either the machine or the application  server domain is down.

==== Service Operation Instance Stays in WORKING Status ====
  * Message Broker Handler crashed.
  * The Message Handler processing the message is on another machine, and either the machine or the application server domain is down.
  * The Message Handler working on the message is blocked. The service will time out, and the Message Dispatcher will retry the message.

==== Unable to Ping a Node ====
  * The web server for the Gateway is down.
  * The Gateway is not configured properly.
  * The application server for the node is down.
  * The Gateway URL is incorrect; verify that the URL is correct.
  * Copy URL in browser address; you should see: \\
   
    PeopleSoft Integration Gateway
    PeopleSoft Listening Connector
    Status: ACTIVE
   

==== Queue Is PAUSED ====
Possible cause is that some queues are delivered as paused. Change the status to Run for the service operations to process from New to Working.

===== Unable to find a Routing corresponding to the incoming request message =====
You are sending an async service operation from node A to target node B. The nodes are pingable.  The routing on target database and source database exist and are correct.  The same service operation works fine if you use and "ANY TO LOCAL" routing.

The "ANY TO LOCAL" routing type uses a virtual node ANY when node passwords fail and eliminates node authentication from the equation.  If "ANY TO LOCAL" works, but a standard point to point routing fails, reset the node authentication option to NONE rather than password and try again. If this works, then the node passwords were incorrect. Resetting these should resolve the problem.

Note: You can also see this error if the Message name does not match the //externalservice// operation name. **They have to Match.**

===== Unable to ping nodes. "Issuing node is not a trusted node" or "PSFT Authentication token failed for Node PSFT_HR" =====
Application server log shows:

PSAPPSRV.6475 (32) [10/17/06 22:09:45 VP1@JavaClient IntegrationSvc](3) PeopleSoft Token authentication failed: issuing node PSFT_HR is not a trusted node : PS@JavaClient

Starting with Peopletools 8.48 Integration Broker requires that nodes be //trusted// on both sides before pinging or sending messages.
To fix this, navigate to  Peopletools --> Security Objects --> Single Signon --> "Trust Authentication Tokens issued by these Nodes"  and add the appropriate node names on each side.

2010-05-06

Peoplesoft HRMS Foundation tables

Peoplesoft HRMS Foundation tables

Peoplesoft Foundation tables can be broadly categorized into

1. Organizational tables

2. Personal Information tables

3. Job Tables

1. Organizational Tables

a. Enter company information.

Use the Company component to enter information about a single company or multiple companies in your organization, from the corporate address to general ledger accounts, tax information, and payroll processing information.

Table names: LEGAL_TYPE_TBL

COMPANY_TABLE1

COMPANY_TABLE2_GBL

COMPANY_TABLE3_GB

COMPANY_TABLE4_GBL

b. Define business units.

Table names: a. BUS_UNIT_TBL_HR

b. BUS_UNIT_TBL_HR2

c. BUS_UNIT_OPT_HR

d. BUS_UNIT_TBL_GL

Description: a. Add or update business b. Identify business units in other PeopleSoft applications that are related to a business unit. c. Set system defaults such as Company, Country, and Currency for a specific SetID. d. Review GL business units.

c. Enter agency information.

Use the Agency component (AGENCY_TABLE) to enter information about a single agency or sub-agencies in your organization, from the central agency address to general ledger accounts, tax information, and payroll processing information.

Table names: GVT_COMPANY_TBL7

GVT_COMPANY_TBL8

GVT_COMPANY_TBL9

d. Establish locations.

Use the Locations component to establish physical locations in your organization, such as corporate headquarters, branch offices, remote sales offices, and so forth.

Table names: LOCATION_TABLE1

LOC_BU_SEC

BUS_PHONE_SEC

LOCATION_TBL2_GBL

e. Maintain departments.

After you define company and location data for your enterprise, use the Departments component to define business entities in your organization.

Table names: DEPARTMENT_TBL_GBL

DEPARTMENT_TBL_CA

f. Define establishments.

You use the Establishment component to define distinct physical places of business (establishments) within your company, to enter address information, and to enter regulatory reporting information

Table names: ESTAB_TBL1_GBL

ESTAB_TBL2_GBL

CONTROLLED_ESTABS

g. Set up company locations.

Table names: COMP_LOC_TBL

h. Set up primary permission list preferences

Set predefined TableSet sharing and system-wide defaults for each of your primary permission lists and Set Payroll System and system-wide defaults for each of your permission lists.

Table names: OPR_DEF_TBL_HR

OPR_DEF_TBL_HR2

i. Set up person of interest types

Table Name: POI_TYPE_TBL

Description: This is about tracking Non-employees in an organization.

j. Set up holiday schedules

Table Name: HOLIDAY_SCHED_TBL

Description: Designate holidays for payroll processing.

2. Personal Information Tables

a. Define national ID types.

Table name: NID_TYPE_TABLE

Description: Assign a national ID type to a country code and provide a default or a dummy national ID for a country to use when a person or applicant ID is unavailable.

b. Define address types.

Table name: ADDR_TYPE_TBL

Description: Enter address types and the order in which they are available.

c. Set up additional name information.

Table name: a. NAME_FORMAT_TBL

b. NAME_TYPE_TBL

c. NAME_PREFIX_TABLE

d. NAME_SUFFIX_TABLE

e. TITLE_TBL

Description: a. Define name format types to use on name pages throughout HRMS.

b. Define name types and the order in which they are available.

c. Enter name prefixes that you’ll use when you record name information.

d. Enter name suffixes to use to record name information.

e. Enter titles for use with names.

d. Define citizen status codes.

Table name: CITIZEN_STATUS

Description: Define the citizenship statuses you’ll need to track for various countries. For example, you may need to distinguish between a native, a naturalized citizen, or a permanent resident of a particular country.

3. Job Tables

a. Define job families.

Create job families to group similar jobs.

Table name: JOB_FAMILY_TABLE

b. Classify jobs.

In HRMS, you identify jobs by job codes, and you maintain information about jobs independent of the person or group performing that job.

Table name: JOBCODE_TBL1_GBL

JOBCODE_TBL2_GBL

JOBCODE_BU

JOBCD_COMP_RATE

JOBCD_NON_BASE

c. Define job tasks.

Define job task codes, such as Data Entry, and assign it to a Job Code on the Job Code Task Table. On the Job Code Task Table, indicate the importance and frequency of the task.

Table name: JOB_TASK_TABLE

JOBCODE_TASK_TABLE

d. Set up pay groups.

When implementing a payroll system for use with HRMS, one of your major tasks is to set up pay groups. For example, you might create different pay groups for employees with different sets of benefits or earnings.

While pay groups may seem specific to payroll processing, you also need this information for Human Resources, to set up job records and benefit programs.

Table name: PAYGROUP_TABLE1

PAYGROUP_TABLE2

PAYGROUP_TBL3

Integration Broker:: manipulate the stuck messages

PSAPMSGPUBHDR - Message Instance Queue
- Youre probably not stuck here.

PSAPMSGPUBCON - Pub Contract Queue
- Youre probably stuck here.
- Shut down messaging servers.
- Update the status.
- Bring up messaging servers.

2009-09-07

SQL*Plus configuration

SQL*Plus: Loading your own custom environment automatically on startup

To customize your SQL*Plus environment and have it assign your preferences from one session to the next, you will want to edit one or both of its auto-startup scripts. The way SQL*Plus behaves on startup is:

  1. It searches for the file $ORACLE_HOME/qlplus/admin/glogin.sql and, if found, executes any commands it contains. This "global" login script applies to everyone who executes SQL*Plus from that Oracle home, no matter which directory they start in.

  2. Next, it runs the file login.sql in the current directory, if it exists.[*]

    [*] If it doesn't exist, and you have set the environment variable SQLPATH to one or more colon-delimited directories, SQL*Plus will search through those directories one at a time and execute the first login.sql that it finds. As a rule, I don't use SQLPATH because I am easily confused by this sort of skulking about.

The startup script can contain the same kinds of statements as any other SQL*Plus script: SET commands, SQL statements, column formatting commands, and the like.

Neither file is required to be present. If both files are present, glogin.sql executes, followed by login.sql; in the case of conflicting preferences or variables, the last setting wins.

Here are a few of my favorite login.sql settings:

    REM Number of lines of SELECT statement output before reprinting headers
SET PAGESIZE 999

REM Width of displayed page, expressed in characters
SET LINESIZE 132

REM Enable display of DBMS_OUTPUT messages. Use 1000000 rather than
REM "UNLIMITED" for databases earlier than Oracle Database 10g Release 2
SET SERVEROUTPUT ON SIZE UNLIMITED FORMAT WRAPPED

REM Change default to "vi improved" editor
DEFINE _EDITOR = /usr/local/bin/vim

REM Format misc columns commonly retrieved from data dictionary
COLUMN segment_name FORMAT A30 WORD_WRAP
COLUMN object_name FORMAT A30 WORD_WRAP

REM set the prompt (works in SQL*Plus

from Oracle9i Database or later)
SET SQLPROMPT "_USER'@'_CONNECT_IDENTIFIER > "

In iSQL*Plus, there is no notion of the current directory, so there is no way to have a personal login.sql file. Only the glogin.sql on the server running iSQL*Plus has any effect.

2009-04-07

Run SQR without PeopleSoft process scheduler

That's easy enough:
1. install SQR (Hyperion's product, downloadable from Oracle);
2. config your SQR client with your database;
3. when you run your sqr from command line, remember to specify your username/password/database_service_name (don't leak your password);
3+. Typically, you need to specify your "SQR_INCLUDE_DIR", by typing the string into your command:
sqr sqr_test.sqr /@ -I;

Don't forget to end up your DIR name string with "\" or "/"; ortherwise it won't work.

2008-12-09

Removal of a Process Def......

The easiest way, if you have two environments (like a development and a test
environment), would be to insert the process definition into a project on
one database, select an upgrade action of "Delete," and perform an upgrade
copy to the other. When you're done, upgrade copy it back to delete it from
the source.

Alternatively, you can delete them using your SQL tool by deleting from the
underlying Tools tables. Be sure to hit all the child tables, too:

delete from ps_prcsdefn where prcstype = 'XXXX' and prcsname = 'YYYY';
delete from ps_prcsdefngrp where prcstype = 'XXXX' and prcsname = 'YYYY';
delete from ps_prcsdefnpnl where prcstype = 'XXXX' and prcsname = 'YYYY';
delete from ps_prcsdefnxfer where prcstype = 'XXXX' and prcsname = 'YYYY';
delete from ps_prcsdefnnotify where prcstype = 'XXXX' and prcsname = 'YYYY';
delete from ps_prcsdefnlang where prcstype = 'XXXX' and prcsname = 'YYYY';
delete from ps_prcsdefncntdist where prcstype = 'XXXX' and prcsname'YYYY';

There is no way to delete them from the Process Definition component.


2008-09-11

陈皓《跟我一起写 Makefile》

陈皓《跟我一起写 Makefile》
http://blog.csdn.net/haoel/archive/2004/02/24/2886.aspx
概述——
什么是makefile?或许很多Winodws的程序员都不知道这个东西,因为那些Windows的IDE都为你做了这个工作,但我觉得要作一个好的和professional的程序员,makefile还是要懂。这就好像现在有这么多的HTML的编辑器,但如果你想成为一个专业人士,你还是要了解HTML的标识的含义。特别在Unix下的软件编译,你就不能不自己写makefile了,会不会写makefile,从一个侧面说明了一个人是否具备完成大型工程的能力。
因为,makefile关系到了整个工程的编译规则。一个工程中的源文件不计数,其按类型、功能、模块分别放在若干个目录中,makefile定义了一系列的规则来指定,哪些文件需要先编译,哪些文件需要后编译,哪些文件需要重新编译,甚至于进行更复杂的功能操作,因为makefile就像一个Shell脚本一样,其中也可以执行操作系统的命令。
makefile带来的好处就是——“自动化编译”,一旦写好,只需要一个make命令,整个工程完全自动编译,极大的提高了软件开发的效率。make是一个命令工具,是一个解释makefile中指令的命令工具,一般来说,大多数的IDE都有这个命令,比如:Delphi的make,Visual C++的nmake,Linux下GNU的make。可见,makefile都成为了一种在工程方面的编译方法。
现在讲述如何写makefile的文章比较少,这是我想写这篇文章的原因。当然,不同产商的make各不相同,也有不同的语法,但其本质都是在“文件依赖性”上做文章,这里,我仅对GNU的make进行讲述,我的环境是RedHat Linux 8.0,make的版本是3.80。必竟,这个make是应用最为广泛的,也是用得最多的。而且其还是最遵循于IEEE 1003.2-1992 标准的(POSIX.2)。
在这篇文档中,将以C/C++的源码作为我们基础,所以必然涉及一些关于C/C++的编译的知识,相关于这方面的内容,还请各位查看相关的编译器的文档。这里所默认的编译器是UNIX下的GCC和CC。

关于程序的编译和链接——————————
在此,我想多说关于程序编译的一些规范和方法,一般来说,无论是C、C++、还是pas,首先要把源文件编译成中间代码文件,在Windows下也就是 .obj 文件,UNIX下是 .o 文件,即 Object File,这个动作叫做编译(compile)。然后再把大量的Object File合成执行文件,这个动作叫作链接(link)。
编译时,编译器需要的是语法的正确,函数与变量的声明的正确。对于后者,通常是你需要告诉编译器头文件的所在位置(头文件中应该只是声明,而定义应该放在C/C++文件中),只要所有的语法正确,编译器就可以编译出中间目标文件。一般来说,每个源文件都应该对应于一个中间目标文件(O文件或是OBJ文件)。
链接时,主要是链接函数和全局变量,所以,我们可以使用这些中间目标文件(O文件或是OBJ文件)来链接我们的应用程序。链接器并不管函数所在的源文件,只管函数的中间目标文件(Object File),在大多数时候,由于源文件太多,编译生成的中间目标文件太多,而在链接时需要明显地指出中间目标文件名,这对于编译很不方便,所以,我们要给中间目标文件打个包,在Windows下这种包叫“库文件”(Library File),也就是 .lib 文件,在UNIX下,是Archive File,也就是 .a 文件。
总结一下,源文件首先会生成中间目标文件,再由中间目标文件生成执行文件。在编译时,编译器只检测程序语法,和函数、变量是否被声明。如果函数未被声明,编译器会给出一个警告,但可以生成Object File。而在链接程序时,链接器会在所有的Object File中找寻函数的实现,如果找不到,那到就会报链接错误码(Linker Error),在VC下,这种错误一般是:Link 2001错误,意思说是说,链接器未能找到函数的实现。你需要指定函数的Object File.
好,言归正传,GNU的make有许多的内容,闲言少叙,还是让我们开始吧。

Makefile 介绍———————
make命令执行时,需要一个 Makefile 文件,以告诉make命令需要怎么样的去编译和链接程序。
首先,我们用一个示例来说明Makefile的书写规则。以便给大家一个感兴认识。这个示例来源于GNU的make使用手册,在这个示例中,我们的工程有8个C文件,和3个头文件,我们要写一个Makefile来告诉make命令如何编译和链接这几个文件。我们的规则是: 1)如果这个工程没有编译过,那么我们的所有C文件都要编译并被链接。 2)如果这个工程的某几个C文件被修改,那么我们只编译被修改的C文件,并链接目标程序。 3)如果这个工程的头文件被改变了,那么我们需要编译引用了这几个头文件的C文件,并链接目标程序。
只要我们的Makefile写得够好,所有的这一切,我们只用一个make命令就可以完成,make命令会自动智能地根据当前的文件修改的情况来确定哪些文件需要重编译,从而自己编译所需要的文件和链接目标程序。
一、Makefile的规则
在讲述这个Makefile之前,还是让我们先来粗略地看一看Makefile的规则。
target ... : prerequisites ... command ... ...
target也就是一个目标文件,可以是Object File,也可以是执行文件。还可以是一个标签(Label),对于标签这种特性,在后续的“伪目标”章节中会有叙述。
prerequisites就是,要生成那个target所需要的文件或是目标。
command也就是make需要执行的命令。(任意的Shell命令)
这是一个文件的依赖关系,也就是说,target这一个或多个的目标文件依赖于prerequisites中的文件,其生成规则定义在command中。说白一点就是说,prerequisites中如果有一个以上的文件比target文件要新的话,command所定义的命令就会被执行。这就是Makefile的规则。也就是Makefile中最核心的内容。
说到底,Makefile的东西就是这样一点,好像我的这篇文档也该结束了。呵呵。还不尽然,这是Makefile的主线和核心,但要写好一个Makefile还不够,我会以后面一点一点地结合我的工作经验给你慢慢到来。内容还多着呢。:)
二、一个示例
正如前面所说的,如果一个工程有3个头文件,和8个C文件,我们为了完成前面所述的那三个规则,我们的Makefile应该是下面的这个样子的。
edit : main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o cc -o edit main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o
main.o : main.c defs.h cc -c main.c kbd.o : kbd.c defs.h command.h cc -c kbd.c command.o : command.c defs.h command.h cc -c command.c display.o : display.c defs.h buffer.h cc -c display.c insert.o : insert.c defs.h buffer.h cc -c insert.c search.o : search.c defs.h buffer.h cc -c search.c files.o : files.c defs.h buffer.h command.h cc -c files.c utils.o : utils.c defs.h cc -c utils.c clean : rm edit main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o
反斜杠(\)是换行符的意思。这样比较便于Makefile的易读。我们可以把这个内容保存在文件为“Makefile”或“makefile”的文件中,然后在该目录下直接输入命令“make”就可以生成执行文件edit。如果要删除执行文件和所有的中间目标文件,那么,只要简单地执行一下“make clean”就可以了。
在这个makefile中,目标文件(target)包含:执行文件edit和中间目标文件(*.o),依赖文件(prerequisites)就是冒号后面的那些 .c 文件和 .h文件。每一个 .o 文件都有一组依赖文件,而这些 .o 文件又是执行文件 edit 的依赖文件。依赖关系的实质上就是说明了目标文件是由哪些文件生成的,换言之,目标文件是哪些文件更新的。
在定义好依赖关系后,后续的那一行定义了如何生成目标文件的操作系统命令,一定要以一个Tab键作为开头。记住,make并不管命令是怎么工作的,他只管执行所定义的命令。make会比较targets文件和prerequisites文件的修改日期,如果prerequisites文件的日期要比targets文件的日期要新,或者target不存在的话,那么,make就会执行后续定义的命令。
这里要说明一点的是,clean不是一个文件,它只不过是一个动作名字,有点像C语言中的lable一样,其冒号后什么也没有,那么,make就不会自动去找文件的依赖性,也就不会自动执行其后所定义的命令。要执行其后的命令,就要在make命令后明显得指出这个lable的名字。这样的方法非常有用,我们可以在一个makefile中定义不用的编译或是和编译无关的命令,比如程序的打包,程序的备份,等等。
三、make是如何工作的
在默认的方式下,也就是我们只输入make命令。那么,
1、make会在当前目录下找名字叫“Makefile”或“makefile”的文件。 2、如果找到,它会找文件中的第一个目标文件(target),在上面的例子中,他会找到“edit”这个文件,并把这个文件作为最终的目标文件。 3、如果edit文件不存在,或是edit所依赖的后面的 .o 文件的文件修改时间要比edit这个文件新,那么,他就会执行后面所定义的命令来生成edit这个文件。 4、如果edit所依赖的.o文件也存在,那么make会在当前文件中找目标为.o文件的依赖性,如果找到则再根据那一个规则生成.o文件。(这有点像一个堆栈的过程) 5、当然,你的C文件和H文件是存在的啦,于是make会生成 .o 文件,然后再用 .o 文件生命make的终极任务,也就是执行文件edit了。
这就是整个make的依赖性,make会一层又一层地去找文件的依赖关系,直到最终编译出第一个目标文件。在找寻的过程中,如果出现错误,比如最后被依赖的文件找不到,那么make就会直接退出,并报错,而对于所定义的命令的错误,或是编译不成功,make根本不理。make只管文件的依赖性,即,如果在我找了依赖关系之后,冒号后面的文件还是不在,那么对不起,我就不工作啦。
通过上述分析,我们知道,像clean这种,没有被第一个目标文件直接或间接关联,那么它后面所定义的命令将不会被自动执行,不过,我们可以显示要make执行。即命令——“make clean”,以此来清除所有的目标文件,以便重编译。
于是在我们编程中,如果这个工程已被编译过了,当我们修改了其中一个源文件,比如file.c,那么根据我们的依赖性,我们的目标file.o会被重编译(也就是在这个依性关系后面所定义的命令),于是file.o的文件也是最新的啦,于是file.o的文件修改时间要比edit要新,所以edit也会被重新链接了(详见edit目标文件后定义的命令)。
而如果我们改变了“command.h”,那么,kdb.o、command.o和files.o都会被重编译,并且,edit会被重链接。
四、makefile中使用变量
在上面的例子中,先让我们看看edit的规则:
edit : main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o cc -o edit main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o
我们可以看到[.o]文件的字符串被重复了两次,如果我们的工程需要加入一个新的[.o]文件,那么我们需要在两个地方加(应该是三个地方,还有一个地方在clean中)。当然,我们的makefile并不复杂,所以在两个地方加也不累,但如果makefile变得复杂,那么我们就有可能会忘掉一个需要加入的地方,而导致编译失败。所以,为了makefile的易维护,在makefile中我们可以使用变量。makefile的变量也就是一个字符串,理解成C语言中的宏可能会更好。
比如,我们声明一个变量,叫objects, OBJECTS, objs, OBJS, obj, 或是 OBJ,反正不管什么啦,只要能够表示obj文件就行了。我们在makefile一开始就这样定义:
objects = main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o
于是,我们就可以很方便地在我们的makefile中以“$(objects)”的方式来使用这个变量了,于是我们的改良版makefile就变成下面这个样子:
objects = main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o
edit : $(objects) cc -o edit $(objects) main.o : main.c defs.h cc -c main.c kbd.o : kbd.c defs.h command.h cc -c kbd.c command.o : command.c defs.h command.h cc -c command.c display.o : display.c defs.h buffer.h cc -c display.c insert.o : insert.c defs.h buffer.h cc -c insert.c search.o : search.c defs.h buffer.h cc -c search.c files.o : files.c defs.h buffer.h command.h cc -c files.c utils.o : utils.c defs.h cc -c utils.c clean : rm edit $(objects)
于是如果有新的 .o 文件加入,我们只需简单地修改一下 objects 变量就可以了。
关于变量更多的话题,我会在后续给你一一道来。
五、让make自动推导
GNU的make很强大,它可以自动推导文件以及文件依赖关系后面的命令,于是我们就没必要去在每一个[.o]文件后都写上类似的命令,因为,我们的make会自动识别,并自己推导命令。
只要make看到一个[.o]文件,它就会自动的把[.c]文件加在依赖关系中,如果make找到一个whatever.o,那么whatever.c,就会是whatever.o的依赖文件。并且 cc -c whatever.c 也会被推导出来,于是,我们的makefile再也不用写得这么复杂。我们的是新的makefile又出炉了。
objects = main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o
edit : $(objects) cc -o edit $(objects)
main.o : defs.h kbd.o : defs.h command.h command.o : defs.h command.h display.o : defs.h buffer.h insert.o : defs.h buffer.h search.o : defs.h buffer.h files.o : defs.h buffer.h command.h utils.o : defs.h
.PHONY : clean clean : rm edit $(objects)
这种方法,也就是make的“隐晦规则”。上面文件内容中,“.PHONY”表示,clean是个伪目标文件。
关于更为详细的“隐晦规则”和“伪目标文件”,我会在后续给你一一道来。
六、另类风格的makefile
即然我们的make可以自动推导命令,那么我看到那堆[.o]和[.h]的依赖就有点不爽,那么多的重复的[.h],能不能把其收拢起来,好吧,没有问题,这个对于make来说很容易,谁叫它提供了自动推导命令和文件的功能呢?来看看最新风格的makefile吧。
objects = main.o kbd.o command.o display.o \ insert.o search.o files.o utils.o
edit : $(objects) cc -o edit $(objects)
$(objects) : defs.h kbd.o command.o files.o : command.h display.o insert.o search.o files.o : buffer.h
.PHONY : clean clean : rm edit $(objects)
这种风格,让我们的makefile变得很简单,但我们的文件依赖关系就显得有点凌乱了。鱼和熊掌不可兼得。还看你的喜好了。我是不喜欢这种风格的,一是文件的依赖关系看不清楚,二是如果文件一多,要加入几个新的.o文件,那就理不清楚了。
七、清空目标文件的规则
每个Makefile中都应该写一个清空目标文件(.o和执行文件)的规则,这不仅便于重编译,也很利于保持文件的清洁。这是一个“修养”(呵呵,还记得我的《编程修养》吗)。一般的风格都是:
clean: rm edit $(objects)
更为稳健的做法是:
.PHONY : clean clean : -rm edit $(objects)
前面说过,.PHONY意思表示clean是一个“伪目标”,。而在rm命令前面加了一个小减号的意思就是,也许某些文件出现问题,但不要管,继续做后面的事。当然,clean的规则不要放在文件的开头,不然,这就会变成make的默认目标,相信谁也不愿意这样。不成文的规矩是——“clean从来都是放在文件的最后”。
上面就是一个makefile的概貌,也是makefile的基础,下面还有很多makefile的相关细节,准备好了吗?准备好了就来。
原文地址 http://blog.csdn.net/haoel/archive/2004/02/24/2887.aspx