Generate Excel report using P4QFOCUS - focus

I have a requirement to generate an Excel report using P4QFOCUS.
If the input file has data, then print the data in excel sheet,
If there is no record in input file,then print only message "file is empty" in excel sheet.
Eg:
input file:
01 james 25
05 john 18
If input file has records then,Excel sheet should be generated as below,
RollNo Name Age
01 james 25
05 john 18
If no records are present in input file then, excel sheet should be generated as,
"file is empty"
I am expecting the logic for Focus step, if focus step is ready,then i will have a mail step to send the report to the mail id as an excel format.
Please find the code below, which i have tried.
TABLE FILE <Table name>
COUNT <Roll No> NOPRINT
IF COUNT NE 0
PRINT Roll-No AS 'Roll No'
Name AS 'NAME'
Age AS 'Age'
ELSE
IF COUNT EQ 0
PRINT
HEADING CENTER
"File is empty"

Related

Row and column integer error when calling load

I have a simple spreadsheet in Excel 97-2003 format, extension is XLS, that is throwing the following error when trying to load it with PHPSpreadSheet.
Error 0 on line 49 in \PhpSpreadsheet\Cell\CellAddress.php -> Row and Column Ids must be positive integer values
The spreadsheet has 14 columns with no formulas or external references. Similar spreadsheets in the same format load and process without error.
require 'PHPSpreadsheet/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls();
$spreadsheet = $reader->load($inputfile); // <-- this is where the failure happens
If I create a new spreadsheet and copy the rows from the one that fails into the new one the load works just fine. The header row and 1 row of data are shown below. I have tried removing the header row and manually entering a single row but get the same failure.
It seems to be related to the file itself but the error message isn't helping to determine exactly what the problem is.
DATE Course ID Title of Class StartTime PGH Location Address City State Zip Code Sponsor/Vendor Instructor if Known Contact Information Telephone
1/10/2023 7280801 Dual Credit Water & Wastewater Workshop 08:00 6 Anywhere Fire Department 123 Main St Any Town NC 28580 NC Statewide Safety Conference, Inc. Sam Smith Joe Smith 252-555-1212
This was caused by a bug in PHPSpreadsheet that was revealed by having a vertical break in row H0 for some reason.
Removing the breaks in the spreadsheet manually would also correct the problem but the latest version of PHPSpreadsheet has been fixed so it will not thrown an error if there is a vertical break in the first row.

Subtract 1 from all the following record key after deleting a specific one

i want to delete a specific item then subtract 1 from all the following item-id so it would look like something like this:
item-id item-name qty price
[01] Item 1 10 99
[02] Item 2 10 99
[03] Item 3 10 99
[04] Item 4 33 23
[05] Item 5 22 33
-Delete item-id 03
new output:
item-id item-name qty price
[01] Item 1 10 99
[02] Item 2 10 99
[03] Item 4 33 23
[04] Item 5 22 33
ive tried something like this the delete works correctly i just dont know how to subtract 1 from all the following item-id's
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INVENTORY
ASSIGN TO 'C:\Users\User\Desktop\FINALS\inventory.dat'
ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM
RECORD KEY IS ITEM-ID.
FILE SECTION.
FD INVENTORY.
01 FILE-INVENTORY.
02 ITEM-ID PIC 9(2).
02 ITEM-NAME PIC X(25).
02 QTY PIC Z99.
02 PRICE PIC ZZZ9.00.
WORKING-STORAGE SECTION.
01 WS-INVENTORY.
02 WS-ID PIC 9(2).
02 WS-GA PIC X(25).
02 WS-QTY PIC 999.
02 WS-PRC PIC 9999.00.
01 WS-EOF PIC A(4).
PROCEDURE DIVISION.
DEL-ITEM.
OPEN I-O INVENTORY
DISPLAY " ENTER ID OF THE PRODUCT YOU WANT TO DELETE"
DISPLAY " ITEM ID: " WITH NO ADVANCING
ACCEPT ITEM-ID
MOVE ITEM-ID TO WS-ID
DELETE INVENTORY
INVALID KEY
DISPLAY "ITEM DOES NOT EXIST"
END-DELETE
MOVE WS-ID TO ITEM-ID
READ INVENTORY NEXT INTO WS-INVENTORY
NOT AT END PERFORM ID-CHECK UNTIL WS-EOF = 'TRUE'
AT END MOVE 'TRUE' TO WS-EOF
CLOSE INVENTORY
ID-CHECK.
SUBTRACT 1 FROM WS-ID GIVING ITEM-ID REWRITE FILE-INVENTORY.
When using DELETE to remove a record, the DELETE statement must be preceded by a successful READ statement. For example,
READ INVENTORY KEY ITEM-ID
INVALID KEY
SET some-error-condition TO TRUE
NOT INVALID KEY
DELETE INVENTORY
more tests for errors
END-DELETE
END-READ
After successfully deleting the record, a loop is needed to change the prime record key of the remaining records.
Note that when changing the prime record key, REWRITE cannot be used. For ACCESS MODE IS RANDOM, use something like the following as a more complete example,
01 WS-DELETE-KEY PIC 99.
01 WS-DELETE-STATUS PIC 9 VALUE 0.
88 RECORD-NOT-FOUND VALUE 1.
88 RECORD-DELETED VALUE 2.
88 DELETE-FAILED VALUE 3.
88 NO-MORE-RECORDS VALUE 4.
ACCEPT WS-DELETE-KEY
PERFORM DELETE-RECORD
IF RECORD-DELETED
ADD 1 TO WS-DELETE-KEY
PERFORM CHANGE-PRIMARY-KEY *> for the remaining records
VARYING WS-DELETE-KEY FROM WS-DELETE-KEY BY 1
UNTIL NO-MORE-RECORDS
END-PERFORM
END-IF
.
DELETE-RECORD.
MOVE WS-DELETE-KEY TO ITEM-ID
READ INVENTORY KEY ITEM-ID
INVALID KEY
SET RECORD-NOT-FOUND TO TRUE
NOT INVALID KEY
DELETE INVENTORY
INVALID KEY
SET DELETE-FAILED TO TRUE
NOT INVALID KEY
SET RECORD-DELETED TO TRUE
END-DELETE
END-READ
.
CHANGE-PRIMARY-KEY.
MOVE WS-DELETE-KEY TO ITEM-ID
READ INVENTORY KEY ITEM-ID
INVALID KEY
SET NO-MORE-RECORDS TO TRUE
NOT INVALID KEY
DELETE INVENTORY
SUBTRACT 1 FROM ITEM-ID
WRITE FILE-INVENTORY
END-READ
This assumes that all remaining records are sequentially numbered and that the failure to read a record means there are no more records.
It may be wise to add additional checks in CHANGE-PRIMARY-KEY for other errors after the DELETE and WRITE statements.
For ACCESS MODE IS DYNAMIC the code is similar but could use START and READ ... NEXT statements.
You probably shouldn't be doing this. It's almost always a bad idea to change a primary key, because it can result in undefined behavior, i.e. you could mess up any other programs that use that file, especially if they have it open concurrently. It also could create a race condition. To be totally safe, kill all other running processes that could be potentially accessing the file using OS SYSTEM calls, open the input file with a lock, open an output file, re-write the file with the new keys under a different name (skipping that record of course), close the output file, close the input file, delete the input file, then rename the output file to the original name. Then you can restart any processes that use it.
A primary key isn't meant to be a meaningful data value, if it is, it is a "smell" that perhaps you should rethink your schema design. If your goal is to read an index file sequentially, then open it with ACCESS IS SEQUENTIAL and READ NEXT RECORD. That way it won't matter what the explicit key values are, or if there are gaps. if you are reading it later with ACCESS IS RANDOM, just include an INVALID KEY clause in your read to handle the missing key. What if there is another index file that has the deleted record key saved in a field as a foreign key? If so, you have just created an orphan and blown your referential integrity.
As a matter of fact, before doing this, you need to know for sure that this is not the case, otherwise, you should delete any other index file records that reference this one as a cascade, or check any other files that might have this key as a foreign key, and not allow the delete if they do, assuming you are in full control of the schema. Cheers!

How to use restricted data validation in Google sheet

I have a following variables in a google sheet.
Google Sheet - https://docs.google.com/spreadsheets/d/19e7lLR__qfd-Lf5d1pr38ezMRvUXc_IXFuqliwMMOao/edit?usp=sharing
Product id Description Mfg. type Value
123 Test Warehouse 0
124 Test Retail store 100
125 Test Retail store 250
126 Test Retail store
127 Test Warehouse
I have kept some data validation in Value column. In addition to that, I want to restrict someone that they can only choose or enter value >0 in Value column if the Mfg. type is Retail Store else we need to show some error message on pop-up to user that "You are not permitted to change the value for Mfg. type Warehouse".
try:
=((C2="Warehouse")*(D2=0))+((C2="Retail store")*(D2>=0)*(D2<=250))

SQLPLUS Column Format and Select query executed simultaneously

I was curious if there was a way in SQLPLUS to run the column format option as well as the select query in one line? instead of having to run each format column line individually. for example:
((column "Role" heading "Role" Format a30,
column "User ID" heading "User ID" Format a5,
column "Password" heading "Password" format a8,
column "Group" heading "Group" format a50,
column "User Name" heading "User Name" Format a15),
(Select ...);
Thanks for any input!
The COLUMN ... FORMAT command keeps config for a given column until either you exit from SQL*Plus or provide a new format. So NO, it does not apply to a single query and it cannot go inside a single query.
(Oracle reference)

Formatting: Changing Column Headers for SqlPlus Query

I'm having trouble with two formatting issues that I would really appreciate help with:
1) The Days Open column is displaying the number of days properly, but the column name is being overwritten by my conversion command, and
2) I need the Order Date (OOpenDate) to be displayed in the "MM/DD/YYYY" format
Code:
column O_Num heading 'Order|Number' format a6
column OOpenDate heading 'Order|Date' format a10
column (sysdate-OrderOpenDate) heading 'Days|Open' format a4
select O_Num, OOpenDate, to_char(sysdate-OOpenDate, '999')
from Orders
where Status = 'Open';
What its currently displaying:
Order Order
Number Date TO_C
------ --------- ------
100 03-DEC-13 14
What I want it to display as:
Order Order Days
Number Date Open
------ --------- ------
100 12/03/2013 14
Thank you in advance!
The simplest approach would be to alias the "Days Open" column and apply the format mask to the alias
column days_open heading 'Days|Open' format a4;
select O_Num, OOpenDate, to_char(sysdate-OOpenDate, '999') days_open
from Orders
where Status = 'Open';
Otherwise, the column name in your column command would need to exactly match the expression in your SELECT statement (including the to_char, any spaces, etc.) That's possible but it generally makes things rather hard to maintain.

Resources