How to skip records with if else statement - cobol

Can anyone provide me logic for this problem
Only process the gtV with bVH01-iMS-FLG = 'Y' .
1) If not iMS-ORDER, bypass the record , read next record & find next gTV to check. One gTV can have multiple records in the input file gTVFLE.
2) If iMS-ORDER, continue process -> abc00-PROCESS-RECORDS.Need to make sure if any tVL didn't pass the validation/error, then the whole gTV should be held; and then continue to find/read next gTV.

From the limited information you have provided it appears there will be a field on some record that you are reading called BVH01-IMS-FLG, you will need to identify the condition for that using an 88 level, like so:
01 BVH01-IMS-FLAG pic X.
88 PROCESS-THIS-RECORD value 'Y'.
It also seems that you have related records in the gTV file and those need to be processed as a group, so something like this:
Perform Read-gTV-Record
Perform until End-Of-File
If PROCESS-THIS-RECORD
Perform abc00-Process-Records
End-IF
Perform Read-gTV-Record
End-Perform
Really, you need to provide more description of what you are trying to do. Record layouts of the gTV and what it means to be a valid tVL would be helpful.

Related

We giving a task for Lua table but it is not working as expectable

Our task is create a table, and read values to the table using a loop. Print the values after the process is complete. - Create a table. - Read the number of values to be read to the table. - Read the values to the table using a loop. - Print the values in the table using another loop. for this we had written code as
local table = {}
for value in ipairs(table) do
io.read()
end
for value in ipairs(table) do
print(value)
end
not sure where we went wrong please help us. Our exception is
Input (stdin)
3
11
22
abc
Your Output (stdout)
~ no output ~
Expected Output
11
22
abc
Correct Code is
local table1 = {}
local x = io.read()
for line in io.lines() do
table.insert(table1, line)
end
for K, value in ipairs(table1) do
print(value)
end
Let's walk through this step-by-step.
Create a table.
Though the syntax is correct, table is a reserved pre-defined global name in Lua, and thus cannot should not be declared a variable name to avoid future issues. Instead, you'll need to want to use a different name. If you're insistent on using the word table, you'll have to distinguish it from the function global table. The easiest way to do this is change it to Table, as Lua is a case-sensitive language. Therefore, your table creation should look something like:
local Table = {}
Read values to the table using a loop.
Though Table is now established as a table, your for loop is only iterating through an empty table. It seems your goal is to iterate through the io.read() instead. But io.read() is probably not what you want here, though you can utilize a repeat loop if you wish to use io.read() via table.insert. However, repeat requires a condition that must be met for it to terminate, such as the length of the table reaching a certain amount (in your example, it would be until (#Table == 4)). Since this is a task you are given, I will not provide an example, but allow you to research this method and use it to your advantage.
Print the values after the process is complete.
You are on the right track with your printing loop. However, it must be noted that iterating through a table always returns two results, an index and a value. In your code, you would only return the index number, so your output would simply return:
1
2
3
4
If you are wanting the actual values, you'll need a placeholder for the index. Oftentimes, the placeholder for an unneeded variable in Lua is the underscore (_). Modify your for loop to account for the index, and you should be set.
Try modifying your code with the suggestions I've given and see if you can figure out how to achieve your end result.
Edited:
Thanks, Piglet, for corrections on the insight! I'd forgotten table itself wasn't a function, and wasn't reserved, but still bad form to use it as a variable name whether local or global. At least, it's how I was taught, but your comment is correct!

How can i delete the value of a column in powerbuilder?

I have a datawindow with 3 selection criteria. This selection criteria are 3 columns. If the user writes something in one of them, than he can't use the others. If he tries to do that a message aware the user that he can use only one criteria. The problem is that after he deletes or cuts what he wrote before and he tries to write something in another column, the message still pop-up. I think that the buffer still contain the last value. How can i reset it?
I guess you have to nullify the 'deleted' column. I would do it that way: in the 'ItemChanged', post:
if dwo.name = 'yourcolumn' and data = '' then
SetNull(ls_null)
post dw_selection.Setitem(row, dwo.name, ls_null)
end if
This, of course, needs to be adapted to suit your needs.
Check the "itemchanged" event of the datawindow with the returned values:
Return value
Set the return code to affect the outcome of the event:
0 (Default) Accept the data value
1 Reject the data value and do not allow focus to change
2 Reject the data value but allow the focus to change

Ambiguous cache keys

I have a data structure which is like this (the real has more nodes levels):
-------Node 1------
| |
| |
Node A: Node B:
-element 1A1 -element 1B1
-element 1A2 -element 1B2
Each element is identified by parents IDs. Each node and element may store or may don't store some value. The values are inherited from parents. So when I want to find value for 1A2, I:
1) check if value for 1A2 exists
2) if not, check if value for A exists
3) if not, check if value for 1 exists
4) save the first found value
The structure is stored in database and it's much more complex. So the problem is that database queries are too slow. But this structure doesn't change often, so I decided to build a server-side cache for it. The cache is removed after any changes in the structure and is rebuild when there is the first attempt to read value of some element. The problem is that, when the cache keys are like this:
"1-A-1" for 1A1 value
"1-A-2" for 1A2 value
"1-A" for A value
"1" for 1 value
1A has value and 1A1 doesn't have value but 1A2 does, the first cache stored is "1-A". Then when I try to find value for 1A2, I first search through the cache and there I find the key "1-A" which fits for my element as these are right nodes. So I don't make any query to database as I assume, the value found in the cache is right. But it is not.
How can I solve this problem? Is there any solution? I want to make the least queries as possible, but I always want to find the exact value for given element.

Can you use the JD Edwards Update command to change a field that is also part of the WHERE clause?

In JD Edward's One World (E1) package, is it possible to use the built in Update table function to update a particular field that is also used in the where clause?
The use case is that I am executing a batch process that loops through a series of "unprocessed" records and after processing them, updates the table to show a "processed" status. There are three statuses (Processed, Unprocessed, and Ignored). During my update, I can't simply update all flags to "Processed" without accidentally updating the ones labeled "Ignored".
If PO cProcessedFlag is equal to "U"
Table1.Select
Table1.Fetch Next
While SV File_IO_Status is equal to CO SUCCESS
...
Table1.Fetch Next
End While
End If
Table1.Update
I need to be able to update the processed field here (Table1.Update) while also being able to specify where the field is not "I".
You can select and update records at the same time. No problem doing this (Assuming that DOCO is the primary key of Table1):
Table1.Select
PO cProcessedFlag = BC cProcessedFlag
Table1.Fetch Next
VA mnOrderNumber[DOCO] <- BC mnOrderNumber[DOCO]
While SV File_IO_Status is equal to CO SUCCESS
...
Table1.Update
VA mnOrderNumber[DOCO] = VA mnOrderNumber[DOCO]
ā€œPā€ -> BC cProcessedFlag
Table1.Fetch Next
VA mnOrderNumber[DOCO] <- BC mnOrderNumber[DOCO]
End While
When you write code in ER, the middleware will actually perform an open, select, close etc. for each tableIO. So the handle for the second Table1.FetchNext is very different to the open, select, update, close generated for the Table1.Update

Merge Statement (COBOL)

I was working on a program that needed to use a merge statement to put two files together and sort them. Of course though I would not be here if I didn't have a problem. When I run my program I have to do a little work afterward to add to the output. When it it goes to perform that paragraph it gives an error that says "Merge File out of sequences ORDER-FILE-SOR". Here is my code:
100-MAIN.
MERGE ORDERS-FILE-SORT
ON ASCENDING KEY REQUEST-DATE-S
ON ASCENDING KEY CUST-NUMBER-S
ON ASCENDING KEY CUST-ORDER-NUMBER-S
ON ASCENDING KEY PART-NUMBER-S
USING ORDERS-FILE-PRIOR-IN
ORDERS-FILE-NEW-IN
OUTPUT PROCEDURE 200-FILE-START
STOP RUN.
200-FILE-START.
OPEN OUTPUT ORDERS-FILE-OUT
ACCEPT WS-DATE FROM DATE
MOVE RUN-MONTH TO MONTH-1
MOVE RUN-DAY TO DAY-1
MOVE RUN-YEAR TO YEAR-1
PERFORM 300-NEXT-PAGE
PERFORM UNTIL ARE-THERE-MORE-RECORDS = 'NO '
RETURN ORDERS-FILE-SORT
AT END
MOVE 'NO ' TO ARE-THERE-MORE-RECORDS
NOT AT END
PERFORM 400-PROCESS-FILE
END-RETURN
END-PERFORM.
CLOSE ORDERS-FILE-OUT.
The output it does show is the heading line and it seems to stop at the "RETURN ORDERS-FILE-SORT" line.
Any help would be greatly appreciated as I feel the rest of the program will run just fine, but I can't check it till this is fixed.
The MERGE verb combines two or more identically sequenced files. To have it work, you must have already sorted them according to an identical set of ascending/descending keys.
If your input is not already in that order, you might need to sort each file by REQUEST-DATE-S, CUST-NUMBER-S, CUST-ORDER-NUMBER-S and PART-NUMBER-S

Resources