IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Passing a field name to COBOL program


IBM Mainframe Forums -> COBOL Programming
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
Vkp321

New User


Joined: 05 Jan 2009
Posts: 43
Location: Pune

PostPosted: Wed Dec 09, 2020 8:16 pm
Reply with quote

Hi
Is it possible to pass field name to COBOL program next use that field for database update.

Example:
Database has a feild XYZ
I need to update field XYZ on a database, I want to pass the string XYZ and value 10

how to use string XYZ to identify the variable

Thanks & Regards
PKV
Back to top
View user's profile Send private message
John Del

New User


Joined: 27 Apr 2012
Posts: 42
Location: NY

PostPosted: Thu Dec 10, 2020 3:51 am
Reply with quote

Yes.
Back to top
View user's profile Send private message
Vkp321

New User


Joined: 05 Jan 2009
Posts: 43
Location: Pune

PostPosted: Thu Dec 10, 2020 8:13 pm
Reply with quote

Hi John Del
Could you please help and explain how this can be achieved
Back to top
View user's profile Send private message
John Del

New User


Joined: 27 Apr 2012
Posts: 42
Location: NY

PostPosted: Thu Dec 10, 2020 10:02 pm
Reply with quote

Write a COBOL update program by coding an IF statement for each database field (variable) possible that you think that you might want to update. Then have the program read in an input dataset (or file! or sysin or parm) that each logical record utilizes delimited fields comprised of the selection item, the db field variable to update, and the new value for that field. Program unstrings the input, validates what it read in for numerics, valid ranges, valid values, etc, and then does the update of the dbFieldVariable to the new value.

Input sample:

selectionItem|databaseFieldVariable|newValue

To help build your "IF" statements quickly for the COBOL program processing routine, obtain a listing of the database dictionary in a dataset and you could easily use sort to build generic "IF and "MOVE" statements for each field/variable in the database data dictionary.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2789
Location: NYC,USA

PostPosted: Fri Dec 11, 2020 12:30 am
Reply with quote

why would you want to invent something like this ? Do you want to do a mass update ? Who gave you such requirements or you are simply doing one of those FAQ tests? There are various methods to do a mass updates but you need to list the original requirements.
Back to top
View user's profile Send private message
Vkp321

New User


Joined: 05 Jan 2009
Posts: 43
Location: Pune

PostPosted: Fri Dec 11, 2020 3:13 pm
Reply with quote

Hi Rohit,
I am thinking of automation some time we get work to update a field which was corrupted and rest is required.

Thanks & Regards
Pradeep
Back to top
View user's profile Send private message
prino
Warnings : 1

Senior Member


Joined: 07 Feb 2009
Posts: 1263
Location: Vilnius, Lithuania

PostPosted: Fri Dec 11, 2020 3:38 pm
Reply with quote

Vkp321 wrote:
I am thinking of automation some time we get work to update a field which was corrupted and rest is required.

Utter imbeciles!

You don't correct a field that has been corrupted, you sort out why it was corrupted in the first place!
Back to top
View user's profile Send private message
Vkp321

New User


Joined: 05 Jan 2009
Posts: 43
Location: Pune

PostPosted: Fri Dec 11, 2020 4:01 pm
Reply with quote

Thank you John Del
What I understood to give SYSIN inputs as per defined field structure

01 FIELD1
02 FIELD2
03 FIELD3

and we want to update FIELD2 with value XX

Provide SYSIN input
02 XX

and in COBOL program accept these values on variable
SEQNO and NWVAL
and have IF statement to identify the field for updation

If SEQNO = 01
MOVE NEWVAL TO FIELD1
END-IF


If SEQNO = 02
MOVE NEWVAL TO FIELD2
END-IF


just curious to know in case any dynamic way is also possible
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10801
Location: italy

PostPosted: Fri Dec 11, 2020 4:15 pm
Reply with quote

Quote:
I am thinking of automation some time we get work to update a field which was corrupted and rest is required.


so ...
if some mission critical data gets corrupted,
the first moron around can run a job without any safety net and without any audit trail icon_cool.gif

wonderful management you have there
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2789
Location: NYC,USA

PostPosted: Fri Dec 11, 2020 6:31 pm
Reply with quote

Vkp321 wrote:
Hi Rohit,
I am thinking of automation some time we get work to update a field which was corrupted and rest is required.

Thanks & Regards
Pradeep

When that happens most of the time you require to fix the upstream and the issue don’t occurs again , second you can write one time program which will update the field to correct value , or use DFSORT/SYNCSORT to overlay the bad value with correct value and most importantly each time you do these updates will go thru a review process . Either of these methods takes no more than few hours but provides you the assurance of correctness.
What you are trying to do sounds interesting but that’s not the way to do in production unless you go thru proper SDLC and complete testing. Second if the database (which you haven’t told yet ) gets added more fields or change if field size the. This program must be changed ( dependable ). Note that take a backup before you do anything with either of the solution as if your process fails then you must have a way to restore else some serious consequences may happen :-)

Good Luck!
Back to top
View user's profile Send private message
Vkp321

New User


Joined: 05 Jan 2009
Posts: 43
Location: Pune

PostPosted: Fri Dec 11, 2020 7:58 pm
Reply with quote

Hi Rohit,

Thank you for sharing your thoughts, every system has few important fields on database and their values are defined so for these fields we can automate the process, yes you are right to take backup before doing such updates

Thanks & Regards
Pradeep
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts IDCAMS listcat service using cobol JCL & VSAM 1
No new posts Make cobol variable value a variable COBOL Programming 3
No new posts how to convert and use 1 bit hex-numb... COBOL Programming 10
No new posts VB file copy COBOL program gives erro... COBOL Programming 3
No new posts Cobol program to determine the sequen... COBOL Programming 2
Search our Forums:

Back to Top