PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Copy Data Definitions  (Read 1203 times)

Tom Anderson

  • Silver Member
  • ***
  • Posts: 31
    • View Profile
Copy Data Definitions
« on: May 23, 2024, 02:48:58 PM »
I have tables defined in the Data Dictionary in PxPlus 2023 version that I need to replicate in the same dictionary.

All of the files are labeled beginning with 'Cx' where x is the company identifier. For example, the customer master file for Company 1 is 'C1ARCUST'.

I need to copy all of the elements in 'C1ARCUST' to 'C2ARCUST'. Everything is identical except for the number at position 2. I see where this is doable one file at a time under Copy but am wondering if the is a bulk copy utility do all of the C1 files at one time.

Thanks!

Tom 

Jim Morton

  • Member
  • **
  • Posts: 13
    • View Profile
Re: Copy Data Definitions
« Reply #1 on: May 23, 2024, 03:11:45 PM »
Here is a routine I use on Windows to copy all files in a directory.
You can tweak it to change the filenames.

40400 COPY_DIR:! ^0200
40410 local fr_file$,to_file$,file_list$,command$
40420 ! needs fully pathed source$ and dest$
40430 source$=sub(source$,"/","\")
40440 call "*dirtree",source$,file_list$,sep,0
40450 while not(nul(file_list$))
40460 fr_file$=file_list$(1,pos(sep=file_list$)-1),file_list$=file_list$(pos(sep=file_list$)+1)
40470 to_file$=sub(fr_file$,source$,dest$)
40472 module$=fr_file$(pos("\"=fr_file$,-2)+1,2)
40474 if pos(module$=module_skip_list$,2) then continue
40480 ! Create any sub directories needed
40490 for i=1 to pos("\"=to_file$,1,0)
40500 directory to_file$(1,pos("\"=to_file$,1,i)),err=*next
40510 next i
40520 erase to_file$,err=*next
40530 command$=env("comspec")+" /c copy "+fr_file$+" "+to_file$
40540 invoke wait hide command$
40550 wend
40560 return

Tom Anderson

  • Silver Member
  • ***
  • Posts: 31
    • View Profile
Re: Copy Data Definitions
« Reply #2 on: May 23, 2024, 05:08:05 PM »
Jim,

I may be looking at this incorrectly but it looks like this simply copies file 'A' to file 'B'.

What I need is to copy the file definition as contained in the files 'providex.dde and providex.ddf leaving the original data definition unchanged.

Tom

Jane Raymond

  • Staff
  • Diamond Member
  • *****
  • Posts: 289
    • View Profile
    • PVX Plus Technologies
Re: Copy Data Definitions
« Reply #3 on: May 27, 2024, 08:32:44 AM »
In the data dictionary, could you change the physical file from 'C1ARCUST' to an expression like "C"+%COMPANY$+"ARCUST"? Then if you set %COMPANY$ to "1" or "2" or whatever you can use the same data dictionary definition for both files.
« Last Edit: May 27, 2024, 03:22:04 PM by Jane Raymond »
Jane Raymond
Software Developer
PVX Plus Technologies Ltd.

Tom Anderson

  • Silver Member
  • ***
  • Posts: 31
    • View Profile
Re: Copy Data Definitions
« Reply #4 on: May 27, 2024, 01:45:23 PM »
Jane,

That's not a bad idea. The problem is that I would need to change the file open logic in 200 - 300 programs.

Would it be feasible to read 'providex.ddf' and 'providex.dde', modify the records containing 'C1' and create a new record for 'C2'?

Thanks!

Tom

Jane Raymond

  • Staff
  • Diamond Member
  • *****
  • Posts: 289
    • View Profile
    • PVX Plus Technologies
Re: Copy Data Definitions
« Reply #5 on: May 27, 2024, 03:28:00 PM »
I wouldn't recommend that approach as there is special logic for assigning the external keys for the ddf file.
Jane Raymond
Software Developer
PVX Plus Technologies Ltd.