Page 1 of 1

Splitting Data

Posted: July 17th, 2018, 3:12 pm
by manishcspro
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.

Re: Splitting Data

Posted: September 10th, 2018, 9:57 am
by Gregory Martin
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:
if MONTH <> tonumber(sysparm("SELECTED_MONTH")) then
    skip case;
endif;

Re: Splitting Data

Posted: October 13th, 2018, 12:56 pm
by manishcspro
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);
--------------------------------------------------------------------

Re: Splitting Data

Posted: October 13th, 2018, 1:04 pm
by manishcspro
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.

Re: Splitting Data

Posted: October 14th, 2018, 11:34 am
by Gregory Martin
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