📄 cmsb37.sqc
字号:
/******************************************************************** ** 源码文件名称 : cmsB37.SQC ** 函数名称 : cms21B037 ** 所属子系统 : CMS ** 当前文件版本 : 1.0.0.0 ** 作 者 : yangjh ** 版本创建日期 : 2005/07/15 ** 功能描述 : 银联中心本代他手续费表打印 ** 修改记录 : ** 修改人 修改日期 修改日期*********************************************************************/#include "sysdefine.h"#include <stdio.h>#include "pubcom.h"#include "funcapi.h"#include "code.h"#include "attrdef.h"#include "cmscode.h"#include "cmsreport03.h"#include "cmsmerchantinfo.h"#include "pubbranchinfo.h"#include "errlog.h"EXEC SQL INCLUDE sqlca;#define OVERPAGE 31 /* 满页行数 */ #define OVERLINE 5 /* 换行行数 */ #define LIMIT 36#define UT_DEBUG 1#undef UT_DEBUG#define PRTLINE \ if( prtline( fp, acFmtFile,acPrtData ) ) \ FUNCERR_PRO \ iLineCount++;/* 打印表头 */#define PRTHEAD \ memset( acPrtData, 0x00, sizeof( acPrtData ) ); \ prtline( fp,"title:" ); \ iLineCount++; \ memset( acPrtData, 0x00, sizeof( acPrtData ) ); \ prtline( fp,"title2:%s", acBankname ); \ iLineCount++; \ memset( acPrtData, 0x00, sizeof( acPrtData ) ); \ prtline( fp,"title3:" ); \ iLineCount++; \ memset( acPrtData, 0x00, sizeof( acPrtData ) ); \ prtline( fp, "title0:%s|%s|%s|%s|%s",pstPubcom->acBrc, \ acYear,acMonth,acDate,acCcyComm); \ iLineCount++; \ memset( acPrtData, 0x00, sizeof( acPrtData ) ); \ prtline( fp, "head:" ); \ iLineCount++; \ iLine ++ ;/* 打印数据 */#define PRTBODY \ memset( acPrtData, 0x00, sizeof( acPrtData ) ); \ prtline( fp, "body:" ); \ iLineCount++; \ memset( acPrtData, 0x00, sizeof( acPrtData ) ); \ prtline( fp,"body0:%s|%s|%s|%s|%s|%s|%s|%s|%s",acRecCntStr,acBrc, \ acTranDevComm,acCommTranKind,acTranDate,acValidfComm,acCntStr,acAmtStr, \ acFeeStr ); \ iLineCount++; \ iLine++; \ iNum++;/* 打印页表尾 */#define PRTFOOT \ memset( acPrtData, 0x00, sizeof( acPrtData ) ); \ prtline( fp, "foot:" ); \ iLineCount++; \ memset( acPrtData, 0x00, sizeof( acPrtData ) ); \ prtline( fp, "foot0:%s|%s|%s",acSumCntStr,acSumAmtStr,acSumFeeStr ); \ iLineCount++; #define BOTTM \ memset( acPrtData, 0x00, sizeof( acPrtData ) ); \ prtline( fp, "footo:" ); \ iLineCount++; \ memset( acPrtData, 0x00, sizeof( acPrtData ) ); \ prtline( fp, "bottm:%s|%s",pstPubcom->acTeller, acPage ); \ iLineCount++; \ iPage++ ; iLine = 0 ; #define INITVARS \ memset( acSettleDate, 0x00, sizeof( acSettleDate ) ); \ memset( acBrc, 0x00, sizeof( acBrc ) ); \ memset( acTranDevType, 0x00, sizeof( acTranDevType ) ); \ memset( acTranKind, 0x00, sizeof( acTranKind ) ); \ memset( acCcy, 0x00, sizeof( acCcy ) ); \ memset( acCommTranKind, 0x00, sizeof( acCommTranKind ) ); \ memset( acCcyComm, 0x00, sizeof( acCcyComm ) ); \ memset( acTranDevComm, 0x00, sizeof( acTranDevComm ) ); \ memset( &iCnt, 0x00, sizeof( iCnt ) ); \ memset( &dAmt, 0x00, sizeof( dAmt ) ); \ memset( &dFee, 0x00, sizeof( dFee ) ); \ memset( acTranDate, 0x00, sizeof( acTranDate ) ); \ memset( &cValidf, 0x00, sizeof( cValidf ) ); #define TRANDEVTYPE_LEN 2#define TRANKIND_LEN 3int cms21B037(pstPubcom)struct pubcom *pstPubcom;{ EXEC SQL BEGIN DECLARE SECTION; char acBrc[BRC_LEN +1]; /* 机构代码 */ char acSettleDate[DATE_LEN + 1 ]; /* 清算日期 */ char acTranDevType[TRANDEVTYPE_LEN + 1 ]; /* 交易地点类型 */ char acTranKind[TRANKIND_LEN + 1 ]; /* 交易种类 */ char acTranDate[DATE_LEN + 1]; /*交易日期*/ char acCcy[BIT4_LEN + 1 ]; /* 币种 */ char acCcyComm[80 ]; /* 币种名称 */ char cValidf ; /* 入帐标志 */ long iCnt ; /* 笔数 */ double dAmt ; /* 金额 */ double dFee ; /* 手续费 */ char acCntStr[9],acAmtStr[25],acFeeStr[25],acValidfComm[15] ; char acSelStr[512]; char acSelStr1[512]; char acInBrc1[BRC_LEN + 1]; /* 输入参数:机构码 */ char acInDate[DATE_LEN + 1]; /* 输入参数:清算日期*/ char acTranDevComm[80],acCommTranKind[80] ; char acCurrentCcy[BIT4_LEN + 1 ]; /* 当前打印币种 */ char acCurrentBrc[BRC_LEN +1]; /* 当前机构代码 */ EXEC SQL END DECLARE SECTION; char acFileName[ 101 ]; char acFmtFile[ 101 ]; FILE *fp, *fmtfp; /* 文件指针 */ int iRecCnt ; /* 序号 */ int iSumCnt = 0 ; /* 笔数合计 */ double dSumAmt = 0.0; /* 金额合计 */ double dSumFee = 0.0; /* 手续费合计*/ char acSumAmtStr[25],acSumFeeStr[25],acSumCntStr[25],acRecCntStr[20]; int iLineCount = 0 ; int i, iPage , iLine, iNum, iFlag; /*iNum:符合条件记录计数*/ char acYear[BIT5_LEN + 1]; char acMonth[BIT3_LEN + 1]; char acDate[BIT3_LEN + 1]; char acPrtData[ 4096 ]; char acBankname[ 41 ]; char acPage[ 5 ]; /* init variables */ memset( acYear, 0x00, sizeof( acYear ) ); memset( acMonth, 0x00, sizeof( acMonth ) ); memset( acDate, 0x00, sizeof( acDate ) ); memset( acBankname, 0x00, sizeof( acBankname ) ); memset( acSelStr, 0x00, sizeof( acSelStr ) ); memset( acInBrc1, 0x00, sizeof( acInBrc1 ) ); memset( acInDate, 0x00, sizeof( acInDate ) ); memset( acCurrentCcy, 0x00, sizeof(acCurrentCcy) ); memset( acPage, 0x00, sizeof( acPage ) ); memset( acBrc, 0x00, sizeof( acBrc ) ); memset( acTranDevComm, 0x00,sizeof(acTranDevComm)); memset( acCommTranKind, 0x00, sizeof(acCommTranKind)); memset( acSumAmtStr, 0x00, sizeof( acSumAmtStr ) ); memset( acSumFeeStr, 0x00, sizeof( acSumFeeStr ) ); iRecCnt = 0 ; iSumCnt = 0; dSumAmt = 0 ; dSumFee = 0 ; if ( pubGetBaseInfo("BANKNAME", acBankname ) ) FUNCERR_PRO strpack(acBankname); sprintf( g_acTrcMsg, "acBankname[%s]", acBankname ); TRCLOG4 /* 取数据字典 */ getstring( "ClearDate", acInDate ); getstring( "Brc1", acInBrc1 ); strpack(acInDate); strpack(acInBrc1); sprintf( g_acTrcMsg, "ClearDate[%s] Brc1[%s]", acInDate,acInBrc1 ); TRCLOG4 /* 赋时间 */ memcpy(acYear, acInDate, 4); memcpy(acMonth,acInDate + 5, 2); memcpy(acDate, acInDate + 8, 2);/* OPEN REPORT FILE */ fp = (FILE *)BeginFile( pstPubcom, NULL ); if ( fp == NULL ) { strcpy( g_acRspCode, "DPS902" ); pubCrtRspInfo( ); ERRLOG goto Exit; }/* OPEN REPORT-FORMAT FILE */ sprintf( acFmtFile, "%s/fmt/cmsB37.fmt", getenv("HOME") ); sprintf( g_acFmtFile, acFmtFile ); if ( ( fmtfp=fopen(acFmtFile,"r") ) == NULL ) { strcpy( g_acRspCode, "DPS902" ); strcpy( g_acTrcMsg, acFmtFile ); TRCLOG4 sprintf( g_acRspMsg, "打开格式文件[%s]错", acFmtFile ); ERRLOG goto Exit ; } iLine = 0 ; iFlag = 0 ; iPage = 1 ; iNum = 0 ; /* generate dynamic sql phase */ sprintf( acSelStr,"SELECT settledate,brc,trandevtype,trankind,ccy,\ trankindcomm,ccycomm,trandevtypecomm,cnt,amt,fee,trandate,validf\ FROM cmsupayfeereg WHERE "); if (strlen(acInBrc1) > 0) { sprintf( acSelStr + strlen(acSelStr), "brc = '%s' ", acInBrc1 ); } else sprintf( acSelStr + strlen(acSelStr), "brc matches \"*\" " ); if (strlen(acInDate) > 0) { sprintf( acSelStr + strlen(acSelStr), "and settledate = '%s' ",acInDate ); } else sprintf( acSelStr + strlen(acSelStr)," and settledate matches \"*\" " ); sprintf( acSelStr + strlen(acSelStr)," ORDER BY settledate, brc, ccy "); sprintf( g_acTrcMsg,"%s", acSelStr ); TRCLOG4 EXEC SQL PREPARE pre1_cur FROM :acSelStr; if ( SQLCODE ) { sprintf( g_acTrcMsg,"SQLCODE[%d]", SQLCODE); TRCLOG4 strcpy( g_acRspCode, "CMS1A7" ); pubCrtRspInfo( SQLCODE ); ERRLOG goto Exit; } EXEC SQL DECLARE report_cur CURSOR FOR pre1_cur; if(SQLCODE) { sprintf( g_acTrcMsg,"SQLCODE[%d]", SQLCODE); TRCLOG4 strcpy( g_acRspCode, "CMS110" ); pubCrtRspInfo("cmsreport03",SQLCODE ); ERRLOG goto Exit ; } SQLOPENCUR(report_cur,"report_cur") if(SQLCODE) { sprintf( g_acTrcMsg,"SQLCODE[%d]", SQLCODE); TRCLOG4 strcpy( g_acRspCode, "CMS111" ); pubCrtRspInfo("cmsreport03",SQLCODE ); ERRLOG goto Exit ; } /* get initial currency code */#ifdef V_INFORMIX EXEC SQL select first 1 unique ccy,ccycomm INTO :acCurrentCcy,:acCcyComm from cmsupayfeereg order by ccy ;#endif#ifdef V_DB2 EXEC SQL select ccy,ccycomm INTO :acCurrentCcy,:acCcyComm from cmsupayfeereg order by ccy FETCH FIRST 1 ROWS ONLY ;#endif if(SQLCODE) { sprintf( g_acTrcMsg,"取起始打印币种错,SQLCODE[%d]", SQLCODE); TRCLOG4 strcpy( g_acRspCode, "CMS111" ); pubCrtRspInfo("cmsreport03",SQLCODE ); ERRLOG goto Exit ; } strpack(acCurrentCcy); /* for test */ #ifdef UT_DEBUG sprintf( g_acTrcMsg, "Initial currency=[%s] \n",acCurrentCcy ); TRCLOG4 #endif /* get initial branch code */ if (strlen(acInBrc1) > 0) { memset( acCurrentBrc, 0x00, sizeof(acCurrentBrc) ) ; strcpy( acCurrentBrc,acInBrc1 ); } else {#ifdef V_INFORMIX EXEC SQL select first 1 unique brc INTO :acCurrentBrc from cmsupayfeereg ORDER by brc ;#endif#ifdef V_DB2 EXEC SQL select brc INTO :acCurrentBrc from cmsupayfeereg ORDER by brc FETCH FIRST 1 ROWS ONLY ;#endif strpack(acCurrentBrc) ; } /* print report head for each new page */ /* 打表头 if( iFlag == 0 ) { PRTHEAD iFlag ++; } */ /* Begin while cycle for generating one report of one currency */ while ( TRUE ) { pubInitCmsreport03(); INITVARS /* Fetch one record from table cmsupayfeereg */ EXEC SQL FETCH report_cur INTO :acSettleDate,:acBrc,:acTranDevType, :acTranKind,:acCcy,:acCommTranKind,:acCcyComm,:acTranDevComm, :iCnt,:dAmt,:dFee,:acTranDate,:cValidf ; if (SQLCODE == SQLNOTFOUND) break; if (SQLCODE) { sprintf( g_acTrcMsg,"SQLCODE[%d]", SQLCODE); TRCLOG4 strcpy( g_acRspCode, "CMS112" ); pubCrtRspInfo("cmsreport03",SQLCODE ); ERRLOG goto Exit ; } strpack(acBrc); strpack(acTranDevType); strpack(acTranKind); strpack(acCcy); strpack(acTranDate); strpack(acSettleDate); strpack(acCommTranKind); strpack(acCcyComm); strpack(acTranDevComm); switch( cValidf ) { case '0': sprintf( acValidfComm,"未入帐" );break ; case '1': sprintf( acValidfComm,"已入帐" );break ; } /* generate new report for new currency */ if( strcmp(acCurrentCcy,acCcy)!=0 || strcmp(acCurrentBrc,acBrc)!=0 ) { /* for test */ #ifdef UT_DEBUG sprintf( g_acTrcMsg,"last currency=[%s],current currency=[%s]\n", acCurrentCcy,acCcy ); TRCLOG4 #endif /* 打印表尾 */ sprintf( acSumCntStr, "%8d", iSumCnt ); sprintf( acSumAmtStr, "%.2lf", dSumAmt ); sprintf( acSumFeeStr, "%.2lf", dSumFee ); /* 赋页数 */ sprintf( acPage, "%d", iPage ); /*for test */ #ifdef UT_DEBUG sprintf( g_acTrcMsg, "now page num=[%d]->[%s] \n",iPage,acPage ); TRCLOG4 #endif PRTFOOT BOTTM if(strcmp(acCurrentCcy,acCcy)!=0) strcpy(acCurrentCcy , acCcy ); if(strcmp(acCurrentBrc,acBrc)!=0) strcpy(acCurrentBrc,acBrc); iRecCnt = 0 ; iSumCnt = 0; dSumAmt = 0 ; dSumFee = 0 ; iFlag = 0 ; } /* end of generating new report for new currency */ /* print report head for each new page */ /* 打表头 */ if( iFlag == 0 ) { strcpy( acCurrentCcy, acCcy ); PRTHEAD iFlag ++; } ++iRecCnt ; iSumCnt += iCnt ; dSumAmt += dAmt ; dSumFee += dFee ; sprintf( acCntStr,"%8d",iCnt); sprintf( acRecCntStr,"%6d",iRecCnt); sprintf( acAmtStr,"%18.2f",dAmt ); sprintf( acFeeStr,"%18.2f",dFee ); /* for test , show record content */ #ifdef UT_DEBUG sprintf(g_acTrcMsg,"acTranDevComm=%s\n",acTranDevComm); TRCLOG4 sprintf( g_acTrcMsg,"%s|%s|%s|%s|%s|%s|%s\n", acBrc,acSettleDate, acTranDevComm,acCommTranKind,acCntStr,acAmtStr,acFeeStr ); TRCLOG4 #endif /* print report body */ PRTBODY /* check whether to add new page */ /* if should add new page ,print pagefoot and pagebottum , */ /* then print new head */ /* reset lineNum count ,pagehead flage , pagenum +1 */ /* 赋页数 */ sprintf( acPage, "%d", iPage ); /* 翻页并且初始化页合计变量 */ if ( iLine % OVERPAGE == 0 ) { /*for test */ #ifdef UT_DEBUG sprintf( g_acTrcMsg, "now page num=[%d]->[%s] \n",iPage,acPage ); TRCLOG4 #endif BOTTM; PRTHEAD } } /* End while cycle for generating one report of one currency */ if( iNum == 0 ) { strcpy( g_acRspCode, "999998" ); sprintf( g_acRspMsg, "无满足条件的纪录!" ); ERRLOG goto Exit ; } /* 打印表尾 */ sprintf( acSumCntStr, "%8d", iSumCnt ); sprintf( acSumAmtStr, "%.2lf", dSumAmt ); sprintf( acSumFeeStr, "%.2lf", dSumFee ); /* 赋页数 */ sprintf( acPage, "%d", iPage ); /*for test */ #ifdef UT_DEBUG sprintf( g_acTrcMsg, "now page num=[%d]->[%s] \n",iPage,acPage ); TRCLOG4 #endif PRTFOOT BOTTMExit: fclose( fp ); fclose( fmtfp ); SQLCLOSECUR(report_cur,"report_cur") if( !strcmp( g_acRspCode, RSP_OK ) ) { SetInqFormid(pstPubcom, "") ; /* for test */ #ifdef UT_DEBUG sprintf( g_acTrcMsg, "subtran 21B037 SUCCESS \n" ); TRCLOG4 #endif return SUCCESS; } else { /* for test */ #ifdef UT_DEBUG sprintf( g_acTrcMsg, "subtran 21B037 failed\n" ); TRCLOG4 #endif return FAILED ; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -