Splitting Data
-
- Posts: 67
- Joined: June 26th, 2017, 2:15 pm
Splitting Data
My data entry application stores data for a quetionnare from month april to march in a financial year. I want to create a menu program to Split data files into seperate month based on parameter pased in menu item. Setoutput function seperates all the data into different months. But i want to seperate only cases which is selected in menu program. I also used sysparm function to create parameter in batch pff but it seperates all the cases in data files.Please help me out with example.
-
- Posts: 1845
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Splitting Data
It will be easier if you post your code so that we can see what you are doing and why it might not work.
However, this could work if you want to split a single month of data to a file:
However, this could work if you want to split a single month of data to a file:
if MONTH <> tonumber(sysparm("SELECTED_MONTH")) then
skip case;
endif;
skip case;
endif;
-
- Posts: 67
- Joined: June 26th, 2017, 2:15 pm
Re: Splitting Data
I have created a batch pff from data entry application to pass the parameter from data entry menu to batch pff,here is the code of data entry to create batch pff
------------------------------------------------------------------------------------------------------------------------
setfile(pffFile,"splitach.pff",create);
filewrite(pffFile,"[Run Information]");
filewrite(pffFile,"Version=CSPro 7.0");
filewrite(pffFile,"AppType=Batch");
filewrite(pffFile,"[Files]");
filewrite(pffFile,"Application=.\splitach.bch");
filewrite(pffFile,"InputData=..\..\..\UPMPR17\achdata\achdata.csdb|CSPRODB)");
filewrite(pffFile,"OutputData=|NONE");
filewrite(pffFile,"Listing=.\splitach.lst");
filewrite(pffFile,"[Parameters]");-
filewrite(pffFile,"Parameter=%S",CONCAT(DIST,ACH_MTH,ACH_YR));
close(pffFile);
execpff(filename(pffFile),wait);
stop(1);
--------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
setfile(pffFile,"splitach.pff",create);
filewrite(pffFile,"[Run Information]");
filewrite(pffFile,"Version=CSPro 7.0");
filewrite(pffFile,"AppType=Batch");
filewrite(pffFile,"[Files]");
filewrite(pffFile,"Application=.\splitach.bch");
filewrite(pffFile,"InputData=..\..\..\UPMPR17\achdata\achdata.csdb|CSPRODB)");
filewrite(pffFile,"OutputData=|NONE");
filewrite(pffFile,"Listing=.\splitach.lst");
filewrite(pffFile,"[Parameters]");-
filewrite(pffFile,"Parameter=%S",CONCAT(DIST,ACH_MTH,ACH_YR));
close(pffFile);
execpff(filename(pffFile),wait);
stop(1);
--------------------------------------------------------------------
-
- Posts: 67
- Joined: June 26th, 2017, 2:15 pm
Re: Splitting Data
I have created a batch pff from data entry application to pass the parameter from data entry menu to batch pff,here is the code of data entry to create batch pff
------------------------------------------------------------------------------------------------------------------------
setfile(pffFile,"splitach.pff",create);
filewrite(pffFile,"[Run Information]");
filewrite(pffFile,"Version=CSPro 7.0");
filewrite(pffFile,"AppType=Batch");
filewrite(pffFile,"[Files]");
filewrite(pffFile,"Application=.\splitach.bch");
filewrite(pffFile,"InputData=..\..\..\UPMPR17\achdata\achdata.csdb|CSPRODB)");
filewrite(pffFile,"OutputData=|NONE");
filewrite(pffFile,"Listing=.\splitach.lst");
filewrite(pffFile,"[Parameters]");-
filewrite(pffFile,"Parameter=%S",CONCAT(DIST,ACH_MTH,ACH_YR));
close(pffFile);
execpff(filename(pffFile),wait);
stop(1);
-----------------------------------------------------------------------------------------------------------------------
my batch file code is here
PROC ACH_QUEST
PREPROC
IF MAKETEXT("%2S%2S%4S",DIST,ACH_MTH,ACH_YR) <> SYSPARM("Parameter") THEN
ENDCASE;
ENDIF;
filedelete("C:/MPR17/monthlybackup/splitted_achdata/*.csdb");
PROC DEPT
setoutput(maketext(".\splitted_achdata\%2S_%2S_%4S.csdb",GETLABEL(DIST_VS1,DIST),ACH_MTH,ACH_YR));
-------------------------------------------------------------------------------------------------------------------------------------
No file is splitted after running this code. I think sysparm function only work with dictionary variables not for declared variables
I want to splite my data based on selection of combined id of Distrcit, Month, Year.
------------------------------------------------------------------------------------------------------------------------
setfile(pffFile,"splitach.pff",create);
filewrite(pffFile,"[Run Information]");
filewrite(pffFile,"Version=CSPro 7.0");
filewrite(pffFile,"AppType=Batch");
filewrite(pffFile,"[Files]");
filewrite(pffFile,"Application=.\splitach.bch");
filewrite(pffFile,"InputData=..\..\..\UPMPR17\achdata\achdata.csdb|CSPRODB)");
filewrite(pffFile,"OutputData=|NONE");
filewrite(pffFile,"Listing=.\splitach.lst");
filewrite(pffFile,"[Parameters]");-
filewrite(pffFile,"Parameter=%S",CONCAT(DIST,ACH_MTH,ACH_YR));
close(pffFile);
execpff(filename(pffFile),wait);
stop(1);
-----------------------------------------------------------------------------------------------------------------------
my batch file code is here
PROC ACH_QUEST
PREPROC
IF MAKETEXT("%2S%2S%4S",DIST,ACH_MTH,ACH_YR) <> SYSPARM("Parameter") THEN
ENDCASE;
ENDIF;
filedelete("C:/MPR17/monthlybackup/splitted_achdata/*.csdb");
PROC DEPT
setoutput(maketext(".\splitted_achdata\%2S_%2S_%4S.csdb",GETLABEL(DIST_VS1,DIST),ACH_MTH,ACH_YR));
-------------------------------------------------------------------------------------------------------------------------------------
No file is splitted after running this code. I think sysparm function only work with dictionary variables not for declared variables
I want to splite my data based on selection of combined id of Distrcit, Month, Year.
-
- Posts: 1845
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Splitting Data
If you use the default Parameter option, then you don't need to specify anything in your sysparm call. Change your code to:
IF MAKETEXT("%2S%2S%4S",DIST,ACH_MTH,ACH_YR) <> SYSPARM() THEN
The other way to do this is something like this:filewrite(pffFile,"DIST=%s",DIST);
filewrite(pffFile,"ACH_MTH=%s",ACH_MTH);
filewrite(pffFile,"ACH_YR=%s",ACH_YR);
// ...
IF DIST <> sysparm("DIST") or ACH_MTH <> sysparm("ACH_MTH") or ACH_YR <> sysparm("ACH_YR") then
filewrite(pffFile,"ACH_MTH=%s",ACH_MTH);
filewrite(pffFile,"ACH_YR=%s",ACH_YR);
// ...
IF DIST <> sysparm("DIST") or ACH_MTH <> sysparm("ACH_MTH") or ACH_YR <> sysparm("ACH_YR") then