Copy Table Record Then Change

jdewannab

Active Member
Hi List,
I am trying to do a simple task and need help with this. I am trying to read a record from a table, change the data, then insert a new record.
Example:
I do a fetch to F0101 and get customer:
Jimi Hendrix - Customer Type: 'C'
I want to change Jimi Hendrix to Stevie Ray Vaughn and then insert a
new f0101 record.

Insert F0101: Customer Stevie Ray Vaughn - Customer Type: 'C'
Result should look like this:
Customer: Jimi Hendrix - Customer Type: 'C'
Customer: Stevie Ray Vaughn - Customer Type: 'C'

Please help me, What is the easiest way this is done.
I am running XE on AS/400 w/ window NT.

Thanks,
Jimmy Berry
 

Frosty the Coder

Legendary Poster
In the example you listed, you'd need to use next numbering to
set ADDRESS NUMBER, which is the key field.

I've had luck by:

Reading (fetching) my source record (Jimi), w/the data going into ER
Variables (all data for a complete record)
change the selected er variables (ie szF0101_ALPH to Stevie).
Lastly Insert, pointing all the er variables to the data.

Again, you need to generate a unique key for the insert to work.....





Gene Piekarski, Jr

AS/400, B733, SP11.2, NT client
AS/400, B733, SP14, W2000 client
 

Zoltan_Gyimesi

Legendary Poster
Hi Jimmy,

If your example is your living problem at the same time and you want to do the copy on not a bunch of records then why don't you use the Copy functionality in the File menu of the Work With Addresses form in the P01012 Address Book application.

If you really want to insert records into the F0101 table then be very carefull what will you change. The original application makes a lot of validation on the datas, further supposly you have to create child records too in an other tables. The best way if you investigate the original Address Book application and/or the interoperability feature for Address Book (If I am right, something exists for AB under XE).

In generall the method is:
1.) Create variables for all field which you want to populate in the Insert.
2.) Fetch the record and populate your variables with the data of the record.
3.) Change values as you want.
4.) Issue the Insert mapping the variables to the fields in the statement.
5.) Always check the File_IO_Status after the Fetch and Insert and act as it is appropriate based on its value (state).

You can put this logic as well into an Interactive Application as well into a Batch Application or Business Function.

A bit hard to answer your issue because its a bit too general.
Please, describe your real problem a bit deteailed making possible for us to help you more (where, why, what, etc.). Thanks.

Zoltán



B7332 SP11, ESU 4116422, Intel NT4, SQL 7 SP1
(working with B7321, B7331, XE too)
 

jdewannab

Active Member
That was just a sample problem, here is my real problem in detail and hopefully one of you can help me with this.

I am adding a modification to P48013 Enter/Change Work Order (menu G3111). The modification is to add a Split on he Work Order. I have made the modifications to split at a certain routing step and creat a new work order, now I have to insert new routing for the new WO.

Problem,
WO Routing for a specific order is in F3112, I need to copy the old routing and change the document #, then do a insert with the new document #. This will create my routing for my new Work Order.

Example of what I am talking about:
1. Create WO document 123 Quantity 10
2. Attach Routing.
WO 123 Sequence 10 Wax Assembly
WO 123 Sequence 20 Mold Construction
WO 123 Sequence 30 Cutoff Parts
3. I Split the WO 123 with a QTY of 5
4. Now I have the following.
WO 123 Qty 5
WO 123 Sequence 10 Wax Assembly
WO 123 Sequence 20 Mold Construction
WO 123 Sequence 30 Cutoff Parts
WO 456 Qty 5
Has not routing, needs to look like WO 123 but with document # 456.

It would be hard to do this by variables because the file is big. I just want to read update the read and insert the new record.

Please help thanks,
 

jdewannab

Active Member
That was just a sample problem, here is my real problem in detail and hopefully one of you can help me with this.

I am adding a modification to P48013 Enter/Change Work Order (menu G3111). The modification is to add a Split on he Work Order. I have made the modifications to split at a certain routing step and creat a new work order, now I have to insert new routing for the new WO.

Problem,
WO Routing for a specific order is in F3112, I need to copy the old routing and change the document #, then do a insert with the new document #. This will create my routing for my new Work Order.

Example of what I am talking about:
1. Create WO document 123 Quantity 10
2. Attach Routing.
WO 123 Sequence 10 Wax Assembly
WO 123 Sequence 20 Mold Construction
WO 123 Sequence 30 Cutoff Parts
3. I Split the WO 123 with a QTY of 5
4. Now I have the following.
WO 123 Qty 5
WO 123 Sequence 10 Wax Assembly
WO 123 Sequence 20 Mold Construction
WO 123 Sequence 30 Cutoff Parts
WO 456 Qty 5
Has not routing, needs to look like WO 123 but with document # 456.

It would be hard to do this by variables because the file is big. I just want to read update the read and insert the new record.

You can e-mail me at [email protected]

Please help thanks,
Jimmy
 

Zoltan_Gyimesi

Legendary Poster
Hi Jimmy,

I am afraid that you can not accomplish this task without a lot of variables and Table I/O mappings unless you write a C++ BSFN.
If you want to do so then could be useful to investigate the "F43092 Copy Rows For Receipt Routing Split" in the B4301450 BSFN. Supposly (see its name) it makes something similar and it is not a large BSFN.

If I am right, you want to do it in an Interactive appl, so if you aren't familiar writing C++ BSFNs under OW then I have an other but not too sophisticated suggestion for you.

1.) Create a Table Conversion UBE.
2.) Set Input/Output Env as Login Env.
3.) Select the same table for input and output.
5.) Create UBE Interconnect to pass the datas for selection and other inputs (and maybe for pass back some flags/counters).
6.) Set selection accordingly.
7.) Place your mapping for the record is fetched event.
8.) Do not forget to mark the the "Issue a write for this event" check-box (Adrian, do you remember :)))
9.) You can easy to use the "Map the same" feature to map all Input fields to the Output fields with a single button-click.
10.) Change your logic for the Document # field.
11.) You can attach additional logic too if you want.
12.) Map your TC UBE to run localy in OCM.
13.) Create a version for your TC UBE.
14.) Call the TC UBE via UBE Interconnect from your APPL, running it Synchronously.

Could it work for you? Hope could be a piece of help.
Please, let us know your results.

Good luck,
Zoltán

B7332 SP11, ESU 4116422, Intel NT4, SQL 7 SP1
(working with B7321, B7331, XE too)
 

jdewannab

Active Member
Hi Zoltan,
I found a way that allows me to do this in a batch UBE. I have the UBE created and did a Report Interconnect from my applications defining my fields that I am going to pass.

Problem is this:
When I run the program and it calls the UBE. it prompts me for the printer screen, I select okay and then look at my report through submitted jobs (View PDF). It will not pull up and I get a error Unable to view output on JDE400. I have checked the application and UBE w/versuib in to the server. Does the UBE have to be deployed to the Enterprise Server for this to work?

Thanks for your expert advice.
Jimmy
 

Zoltan_Gyimesi

Legendary Poster
Hi Jimmy,
I am really glad to read your results. Thanks for your update.

In response to your question: Yes, you have to deploy (via Package) your UBE onto the enterprise server if you want to run it there.

Let me some additional question.

1.) Why do you want to run your UBE on the server?
2.) If you want to run your UBE always localy then create an OCM entry (Object Configuration Manager) for it as I suggested in my previous reply. Do not forget sign-off, sig-on OneWorld to take effect the OCM entry on your workstation session. (I suppose, you know how to create an appropriate entry in OCM. If not then, let us know.)
3.) Is your UBE a Table Conversion? If is not then how have you solved your problem?

Read You Again,
Zoltá

B7332 SP11, ESU 4116422, Intel NT4, SQL 7 SP1
(working with B7321, B7331, XE too)
 

jdewannab

Active Member
Zoltá,
I don't have to run it submitted, I have created a OCM now to run on my local. I prefer the programs run in batch once in production. This should be okay I believe because it will be on the ES at that time.

I am not doing a Table conversion. This is what I am doing and if you see a flaw in it, please let me know.

I have created a report to pull the records of the old WO number and it will write those records in a Report Column. I then change the report column Order Number to the new Order Number and do a write to the file.

Same idea with Flat file, but seemed to be a little easier... What do you think?
Again, thanks for the time you have helped me on this project.

Thanks,
 

Xe_na_thanks

Active Member
What you want to do should be accomplished through using the master business functions provided, i.e;

B3101260 - Parts list master business function.

B3101250 - Routing master business function.

X4801 - Work order master business function.

Examples of all these are available in there respective applications or ubes. I can however provide you of a print of a business function (NER) which creates a new work order and generates parts list and routing based on another work order. It will also automatically superbackflush it if you want.

Regards,

Adrian Jackson.

Xe SP15 Update1 applied AS400 V4R4 DB2, World A73 Cum 11 00X2
 
Top