COBOL - bonus report - count

Need your help with my COBOL assignment.
data division file section details are below. My question is I do not know how to count the number if characters - RECORD CONTAINS _ CHARACTERS. Could you check and tell me if my count is right. If not what is the correct number and how did u arrive at it.
FD BONUS-REPORT
RECORD CONTAINS 222 CHARACTERS.
01 BONUS-REPORT-RECORD PIC X(222).
WORKING-STORAGE SECTION.
01 LINE-CT PIC 99 VALUE 0.
01 WS-CONSTANTS.
05 TOTAL-LINES PIC 99 VALUE 10.
01 ARE-THERE-MORE-RECORDS PIC X(3) VALUE 'YES'.
88 MORE-RECORDS VALUE 'YES'.
88 NO-MORE-RECORDS VALUE 'NO'.
01 WS-DATE.
05 WS-YEAR PIC 9(4).
05 WS-MONTH PIC 99.
05 WS-DAY PIC 99.
01 HDR-1.
05 PIC X(40).
05 PIC X(12)
VALUE 'BONUS REPORT'.
05 PIC X(8).
05 PIC X(5) VALUE 'PAGE'.
05 PAGE-NO PIC 99 VALUE 0.
05 PIC X(4).
05 DATE-OUT.
10 MONTH-OUT PIC 99.
10 PIC X VALUE '/'.
10 DAY-OUT PIC 99.
10 PIC X VALUE '/'.
10 YEAR-OUT PIC 9(4).
01 HDR-2.
05 PIC X(10).
05 PIC X(13)
VALUE 'TERRITORY --'.
05 TERRITORY-NO-OUT PIC X(2).
01 HDR-5.
05 PIC X(20).
05 PIC X(10)
VALUE 'OFFICE -- '.
05 OFFICE-NO-OUT PIC X(2).
01 HDR-7.
05 PIC X(10).
05 PIC X(14)
VALUE 'EMPLOYEE NAME'.
05 PIC X(8).
05 PIC X(5)
VALUE 'BONUS'.
01 DETAIL-LINE.
05 PIC X(7).
05 EMPLOYEE-NAME-OUT PIC X(24).
05 BONUS-OUT PIC $BZ,ZZZ.99 BLANK WHEN ZERO.

I'm not going to count them all and add them up, but it seems like you might be long.
It's not explicitly stated here, but it looks like your record in your BONUS-REPORT is probably a REDEFINES of the HDR-n and DETAIL-LINE, so the count of the longest of these is the record size (assuming fixed length records).
Count BONUS-OUT as 10. There should not be alignment because everything is USAGE IS DISPLAY by default. The VALUE clauses make no difference in the count.

The answer to your question is to ask the compiler for the answer.
That is, compile the program as-is and check the compiler listing and it should tell you how long each field and record is. Then you can go back into the source code and update as needed.
Depending on which enviroment you are using (mainframe, unix, windows, etc.) there might be certain compiler options that need to be set to tell the compiler create that kind of compiler listing. For me using z/OS on the mainframe with the 4.2 release of the compiler, the options are all documented in the Enterprise COBOL for z/OS Programming Guide at http://pic.dhe.ibm.com/infocenter/pdthelp/v1r1/topic/com.ibm.entcobol.doc_4.2/PGandLR/ref/rpcos390.htm.

Strictly speaking bonus record is 222 bytes because that what you say it is:--
01 BONUS-REPORT-RECORD PIC X(222).
What you probably are asking is what is the length of the various header and detail entries.
Normally these would all be written as separate records -- so the longest record would be HDR-1 at 81 bytes. All the others are shorter.

Related

BAD UDP LENGTH > IP PAYLOAD LENGTH (WIRESHARK) - WHY?

I am working on FPGA ETHERNET project. My problem is following :a UDP/IP packet sent from FPGA is captured by "wireshark" and it gives me a following warning : "BAD UDP LENGTH 26 > IP PAYLOAD LENGTH Len=18 (Malformed Packet)".
BAD_UDP_LENGTH(PICTURE)
Actually, I am trying to send the following packet :
55555555555555D598EECB9B6EF400123456789008004500002EB3FE0000801108BDA9FE1504A9FE1503FA00FA00001A45630 00102030405060708090A0B0C0D0E0F1011 06A07518
You can see that the last byte of data is 11 and that part of data is not displayed by "wireshark". That part of data is obviously transmitted as I have seen it on oscilloscope. I have tried the number of different Ethernet Packet generators(PacketETH,EthernetUDP,C#) and all of them have generated the same packets (I think no problem lies in packet or packet generators). Also I have captured packets by different network monitoring software "Omnipeek" which gave me the same result as gave "wireshark" : LAST BYTE IS NOT DISPLAYED
If the last byte displayed, I think "wireshark" wouldn't give me that error.
Does anybody know how to solve that problem ?
Here I will give you additional details :
1) I am using Digilent Anvyl FPGA which has LAN8720A-CP-TR tranceiver. I have written code in VHDL and also run simulation in ISIM which gave me a correct result, concretely: all bits are sent successively with relevant values. Besides, I have checked simulation result in reality by probing LAN8720A-CP-TR tranceiver transmit pins by Digilent Electronics Explorer
2) For Ethernet packet generation I am using a simple program which you can download from here EthernetUDP (fpga4fun.com) here is picture of packet generated by that program EthernetUDP picture
If I copy the frame data from the image, I get this:
0000 98 ee cb 9b 6e f4 00 12 34 56 78 90 08 00 45 00
0010 00 2e b3 fe 00 00 80 11 08 bd a9 fe 15 04 a9 fe
0020 15 03 fa 00 fa 00 00 1a 45 63 00 01 02 03 04 05
0030 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11
0040
And if I save that in a file called packet.txt then run text2pcap packet.txt packet.pcap, then load the resulting capture file back into Wireshark, I get a completely valid packet including the trailing 0x11 byte and the "bytes on wire" is indicated as 60 bytes instead of 59 bytes.
So somehow in your setup, that last byte didn't get handed off to Wireshark; therefore it simply wasn't captured for some reason, which is the reason why it's not displayed. Why it wasn't captured is an open question. It may have been transmitted as you say, since you can see it on the oscilloscope, but something about it or your capture hardware isn't correct.

Initialize variable-length in Cobol

I have a copybook with the folowing:
(...)
05 ESTGWABC-S-OUT.
10 ESTGWABC-S-COD-NUM PIC 9(003).
10 ESTGWABC-S-DESC-COD PIC X(020).
(...)
10 ESTGWABC-S-VAL-PAY PIC 9(015)V99.
10 ESTGWABC-S-QTD-REG PIC 9(002).
10 ESTGWABC-S-REG-PEOP OCCURS 0 TO 20 TIMES
DEPENDING ON ESTGWABC-S-QTD-REG.
15 ESTGWABC-S-CCONTR PIC 9(009).
15 ESTGWABC-S-VAL-PAY PIC 9(015)V99.
10 ESTGWABC-S-DEPEN PIC 9(005).
(...)
On my program, I'm wanting to initialize it before use it, so I'm doing the following:
INITIALIZE ESTGWABC-S-OUT
REPLACING ALPHANUMERIC BY SPACES
NUMERIC BY ZEROS
But I'm getting an compiling error:
"ESTGWABC-S-OUT" was found in an "INITIALIZE" statement but was variable-length or variably located. The operand was discarded from the "INITIALIZE" statement.
Can anybody give me a clue how can I solve it or what am I doing wrong? Thank you very much.
Can anybody give me a clue how can I solve it or what am I doing wrong?
Do not use INITIALIZE and you are doing nothing wrong.
Basically, standard COBOL sets rules for the organization of data records. It then defines the behavior of the INITIALIZE statement to properly operate on those data records.
The data items after the variable length table are 'variably located'. This does not conform to standard COBOL, which requires that any variable length data item, in this case, ESTGWABC-S-REG-PEOP, be located last in the record description entry. The location of ESTGWABC-S-DEPEN will change depending on the number of entries in the table, ESTGWABC-S-REG-PEOP. When the size of the table changes ESTGWABC-S-DEPEN will no longer be an initialized data item.
To allow the use of INITIALIZE, the 'copybook' must be changed.
Following is an example of how to use INITIALIZE with a standard-conforming variable length record. This was done with a Micro Focus compiler with flags to force COBOL 85 conformance.
$set ans85 flag"ans85" flagas"s"
identification division.
program-id. var-len.
data division.
working-storage section.
01 n pic 9(2).
01 a.
02 fixed-part.
03 b pic x(2).
03 c pic 9(2).
02 variable-part.
03 d occurs 0 to 10 depending c.
04 e pic x(2).
04 f pic 9(2).
procedure division.
begin.
initialize fixed-part
perform varying n from 1 by 1 until n > 10
initialize d (n)
end-perform
stop run
.
end program var-len.

Something like |01 00 01 00| in the tcp packet about the snort rule?

This is a snort rule:
alert tcp $EXTERNAL_NET $HTTP_PORTS -> $HOME_NET any (msg:"INFO web bug 0x0 gif attempt"; flow:from_server,established; content:"Content-type|3A| image/gif"; nocase; content:"GIF"; nocase; distance:0; content:"|01 00 01 00|"; distance:3; within:4; content:"|2C|"; distance:0; content:"|01 00 01 00|"; distance:4; within:4; classtype:misc-activity; sid:2925; rev:2;)
From the alert name, I can see it seems to preventing receive html code including 0x0 gif to avoid the bandwidth depletion. I just want to know what is something like |01 00 01 00| here. Please tell me to help me have a better understand of the whole rule.
|01 00 01 00| is width and height value of the GIF.
content:"|01 00 01 00|"; distance:3; within:4; matched 4bytes after GIF89a
Good luck~

FU-A multiple slice NALU per frame RTP packetization

We are doing 2 slices per frame encoding using our codec and we are getting good H264 file output when played on VLC player.
But when we RTP packetize that encoded data and stream to VLC, it shows artifacts. If we use one slice per frame, our packetization is ok and stream on VLC also looks good.
We are using FU-A fragmentation, and my encoded file configuration:
resolution: 640x480
framerate: 30fps
bitrate: 800 Kbps
Our encoder is configured to use High Profile, CBR, IDR every 10 frames.
Our encoder output bitstream looks like:
00 00 00 01 67 [DATA] 00 00 00 01 68 [DATA] 00 00 00 01 65 [DATA] 00 00 00 01 65 [DATA] 00 00 00 01 41 [DATA]
So here we have two successive slice NALUs (0x65).
In our RTP pcap, everything looks good -- FU-A fragmentation, marker bit, etc but VLC and ffplay both show a similar type of artifact, as if the upper half of the frame is stretched (vertically).
My pcap file link:
http://www.filedropper.com/rtp
So I reduced the test case to a small, low bitrate (50 Kbps) QCIF stream with no fragmentation and I am still seeing the same problem.
My pcap file link:
http://www.filedropper.com/rtpqcif
Can any expert please look at the pcap file and see what might be causing VLC such trouble to play stream?
Thank you,
Harshal Patel
Although it's a very old question, when aggregating multiple NAL-U with the same timestamp (like in your example), the packetizer should use STAP-A mode and not FU-A. FU-A is made for a single timestamp NAL-U that would not fit in a RTP packet.
You need to solve the packetizer issue and everything will go well.

Ada interfaces with Cobol

I am studying the Ada-> Cobol interface, and am wondering if there is any way to write the files to cobol default, without having to have a Cobol code written too, because I want to write a file using some rules of COBOL, but would to know how to do this directly in Ada.
For example, to read a file with cobol structure, I can use use that way:
with Interfaces.COBOL;
with COBOL_Sequential_IO; -- Assumed to be supplied by implementation
procedure Test_External_Formats is
112
-- Using data created by a COBOL program
-- Assume that a COBOL program has created a sequential file with
-- the following record structure, and that we need to
-- process the records in an Ada program
-- 01 EMPLOYEE-RECORD
-- 05 NAME PIC X(20).
-- 05 SSN PIC X(9).
-- 05 SALARY PIC 99999V99 USAGE COMP.
-- 05 ADJUST PIC S999V999 SIGN LEADING SEPARATE.
-- The COMP data is binary (32 bits), high-order byte first
113
package COBOL renames Interfaces.COBOL;
114
type Salary_Type is delta 0.01 digits 7;
type Adjustments_Type is delta 0.001 digits 6;
115
type COBOL_Employee_Record_Type is -- External representation
record
Name : COBOL.Alphanumeric(1..20);
SSN : COBOL.Alphanumeric(1..9);
Salary : COBOL.Byte_Array(1..4);
Adjust : COBOL.Numeric(1..7); -- Sign and 6 digits
end record;
pragma Convention (COBOL, COBOL_Employee_Record_Type);
116
package COBOL_Employee_IO is
new COBOL_Sequential_IO(COBOL_Employee_Record_Type);
use COBOL_Employee_IO;
117
COBOL_File : File_Type;
118
type Ada_Employee_Record_Type is -- Internal representation
record
Name : String(1..20);
SSN : String(1..9);
Salary : Salary_Type;
Adjust : Adjustments_Type;
end record;
119
COBOL_Record : COBOL_Employee_Record_Type;
Ada_Record : Ada_Employee_Record_Type;
120
package Salary_Conversions is
new COBOL.Decimal_Conversions(Salary_Type);
use Salary_Conversions;
121
package Adjustments_Conversions is
new COBOL.Decimal_Conversions(Adjustments_Type);
use Adjustments_Conversions;
122
begin
Open (COBOL_File, Name => "Some_File");
123
loop
Read (COBOL_File, COBOL_Record);
124
Ada_Record.Name := To_Ada(COBOL_Record.Name);
Ada_Record.SSN := To_Ada(COBOL_Record.SSN);
Ada_Record.Salary :=
To_Decimal(COBOL_Record.Salary, COBOL.High_Order_First);
Ada_Record.Adjust :=
To_Decimal(COBOL_Record.Adjust, COBOL.Leading_Separate);
... -- Process Ada_Record
end loop;
exception
when End_Error => ...
end Test_External_Formats;
Put, I don't know how to write a File with cobol structure, in the documentation, I not find a way; http://www-users.cs.york.ac.uk/~andy/lrm95/b_04.htm
For example, if I have that struct in Cobol ( based on this sample: http://www.csis.ul.ie/cobol/examples/Sort/MaleSort.htm ; http://www.csis.ul.ie/cobol/examples/SeqIns/STUDENTS.DAT )
FILE SECTION.
FD StudentFile.
01 StudentRec PIC X(30).
88 EndOfFile VALUE HIGH-VALUES.
FD MaleStudentFile.
01 MaleStudentRec PIC X(30).
SD WorkFile.
01 WorkRec.
02 FILLER PIC 9(7).
02 WStudentName PIC X(10).
02 FILLER PIC X(12).
02 WGender PIC X.
88 MaleStudent VALUE "M".
How I can make a program to write this struct, in Ada, using Cobol interfaces ?
Think physically. That is, what is the output file's format? Whether you create that file in Cobol or Ada is NOT an immediate issue when designing a file.
Let's assume that Cobol Workrec describes your file's format. Do you want to write an Ada program that calls a cobol subroutine to physically write the file? or do you want to use a Cobol program to write the file? Or do you want an Ada program that writes a file in the smae format as Workrec?? Your choice depends on your customer's requirements.

Resources