Aug 22, 2012

PeopleSoft : Reserved Variables in SQR


SQR reserves a library of predefined variables for general use.

#current-column : The current column on the page.

$current-date : The current date-time on the local machine when SQR starts running the program.

#end-file : Set to one (1) if end of file occurs when reading a flat file; otherwise, it is set to zero (0).
Your program should check this variable after each READ command.

#page-count : The current page number.

#current-line : The current line on the page.
This value is the physical line on the page, not the line in the report body. See Getting Started with SQR.
Line numbers are referenced in PRINT and other SQR commands used for positioning data on the page.
Optional page headers and footers, defined with BEGIN-HEADING and BEGIN-FOOTING commands,have their own line sequences. Line 2 of the heading is different from line 2 of the report body or footing.

#return-status : Value to be returned to the operating system when SQR exits.
Can be set in your report. #return-status is initialized to the “success” return value for the operating system.

#sql-count : The count of rows affected by a DML statement (INSERT, UPDATE, or DELETE). This is equivalent to ROWCOUNT in Oracle and Sybase.


PeopleSoft : Preventing user from making changes to the field

Gray function:
   
      Gray( ) is used to make the field unavailable to change in page.
 
      Syntax:
                 Gray(scrollpath,targetrow,Record.Fieldname);

      Example:
                 Gray(Record.CH_EMPSTATE, &i, CH_EMPSTATE.STATE);


PeopleSoft : Add Drop-down values through peoplecode


/* Get the field reference into &field variable */

&field = GetRecord(Record.CH_EMPTYPE).GetField(Field.CH_EMPMAIN);


/* Delete all the values from dropdown list */

&field.cleardropdownlist();

/* Add values to the dropdown list */

&field.adddropdownitem(Descr, Value);
   [Value]: It is actual value which is mapped to the dropdown item
   [Descr]: It is actual text which is visible as a dropdown item
Examples:
&field.adddropdownitem("A", "A");
&field.adddropdownitem("B", "B");
&field.adddropdownitem("C", "C");

Aug 20, 2012

PeopleSoft : Handling files in PeopleCode


/*********** To move file data***************/
Exec("cmd /c move " | &file1 | " " | &file2, %Exec_Asynchronous %FilePath_Absolute);

/*********** To copy file data***************/
Exec("cmd /c copy " | &file1 | " " | &file2, %Exec_Asynchronous %FilePath_Absolute);

/*********** To delete the file**************/
Exec("cmd /c del " | &file1, %Exec_Asynchronous %FilePath_Absolute);

***********************************************************OR**********************************************************  
/*********** Create java objects corresponds to files ****************************/                           
Local JavaObject &f = CreateJavaObject("java.io.File", "/the/path/to/the/file.txt"); 
Local JavaObject &target = CreateJavaObject("java.io.File", "/the/target/file.txt"); 

&f.renameTo(&target); 

Local JavaObject &f = CreateJavaObject("java.io.File", "/the/path/to/the/file"); 

&f.delete(); /* delete the file from source */

PeopleSoft : PeopleCode for disable the row delete option in scroll and grid



For &i = 1 To &Asmfloor.ActiveRowCount
   &Asmwing = &Asmfloor(&i).GetRowset(Scroll.ASM_WING_TBL);

   For &j = 1 To &Asmwing.ActiveRowCount
      &Asmcabin = &Asmwing(&j).GetRowset(Scroll.ASM_CABIN_TBL);
   
      If &Asmcabin.ActiveRowCount = 1 Then
         &Asmwing.DeleteEnabled = True; /* to enable the row delete option */

         If &Asmwing.ActiveRowCount = 1 Then
            &Asmfloor.DeleteEnabled = True;
         Else
            &Asmfloor.DeleteEnabled = False; /* to disable the row delete option */
         End-If;
         rem &Asmfloor.DeleteEnabled = True;

      Else
         &Asmwing.DeleteEnabled = False;
         &Asmfloor.DeleteEnabled = False;
       
      End-If;
   
   End-For; /* end-of wing */
             
End-For; /* end-of floor */

PeopleSoft : Convert string to date in SQR

let $dt=strtodate('20120320')

strtodate function converts string to date in sqr report.

PeopleSoft : PeopleCode to find special characters in file other than ASCII characters


Local string &File_path, &File_path1;

&File_path = "C:\temp\ascii.xml";
&bud_rep = GetFile(&File_path, "r", %FilePath_Absolute);
&File_path1 = "C:\temp\ascii_1.txt";
&bud_rep1 = GetFile(&File_path1, "a", %FilePath_Absolute);
&count = 0;

While &bud_rep.readline(&line)
   &line1 = Len(&line);
   &count = &count + 1;

   For &i = 1 To &line1
      &char = Substring(&line, &i, 1);
      &naciichar = Code(&char); /* returns the number corresponds to character */
      /* check whether the character is in the range of ascii char's or not */
      If &naciichar >= 128 Or
            &naciichar < 0 Then
         &bud_rep1.writeline(&count | " " | &char); /* write special character to file */
      End-If;

   End-For;

End-While;