0

我对 webfocus 很陌生,不知道如何创建 WF 脚本来生成 raport。我必须有选择 Template_name、Date、Campaign 的选项,

以下有效的 SQL 脚本是:

SELECT Number_of_Sent_emails, count(*)AS Number_of_Client_IDs
FROM (SELECT mel.CRM_CODE as client_ID, COUNT(mel.EMAIL) as Number_of_Sent_emails
      FROM dw.f_CRM_campaign_header mel 
          -- where    mel.TEMPLATE_NAME = 'cabin__et'
          --  and mel.SEND_DATE_FROM > '2016.02.17' 

        GROUP BY mel.CRM_CODE
     ) a
GROUP BY Number_of_Sent_emails
ORDER BY Number_of_Sent_emails;

在此处输入图像描述

我将添加我编写的代码来创建这个报告。但我不知道如何正确使用它。

-SET &ECHO=ALL;
-INCLUDE IBFS:/WFC/Repository/Public/general_settings.fex
-DEFAULT &DATE_FROM='2015-12-01';
-DEFAULT &DATE_TO='2015-12-05';
-TYPE &DATE_FROM
-SET &CAMPAIGN_TYPE = &CAMPAIGN_TYPE.(OR(FIND CAMPAIGN_TYPE_CODE, CAMPAIGN_TYPE_NAME IN IQ_DW_F_CRM_CAMPAIGN_HEADER)).Campaign Type.;
-SET &TEMPLATE_NAME = &TEMPLATE_NAME.(OR(FIND TEMPLATE_NAME, TEMPLATE_NAME IN IQ_DW_F_CRM_CAMPAIGN_HEADER)).Template Name.;
-SET &CAMPAIGN = &CAMPAING.(OR(FIND CAMPAIGN_NAME, CAMPAIGN_NAME IN IQ_DW_F_CRM_CAMPAIGN_HEADER)). Campaing.;
-SET &REPORT_PART=&REPORT_PART.(OR(<By Citizenship,1>,<By Gender,2>,<By age group,3>,<By Tier Level,4>,<By Campaign,5>,<By Template Name,6>,<By Market Area,7>)). Report Parts.;
-SET &REPORT_DATE = EDIT(&YYMD,'9999') || '/' || EDIT(&YYMD,'$$$$99') || '/' || EDIT(&YYMD,'$$$$$$99');

DEFINE FILE IQ_DW_CRM_CAMPAIGNS
CITIZENSHIP_CODE2/A30=CITIZENSHIP_CODE;
GENDER_DESC2/A30=GENDER_DESC;
AGE_GROUP_ORDER2/A30=AGE_GROUP_ORDER;
CLUB_TIER_LEVEL2/A30=CLUB_TIER_LEVEL;
-*CAMPAIGN2/A30=CAMPAIGN;
-*TEMPLATE_NAME2/A30=TEMPLATE_NAME;
-*MARKET_AREA2/A30=MARKET_AREA;

END


TABLE FILE IQ_DW_CRM_CAMPAIGNS
SUM
     CNT.IQ_DW_CRM_CAMPAIGNS.D_CLIENTS.CLIENT_ID/D12 AS 'MEASURE'
BY  LOWEST IQ_DW_CRM_CAMPAIGNS.D_CLIENTS.CITIZENSHIP_CODE2 AS 'DIMENSION'
BY TOTAL LOWEST COMPUTE DIMENSION_GROUP/A20 = 'By Citizenship';
BY TOTAL LOWEST COMPUTE ORDER/I1=1;
WHERE 1 EQ 2;
ON TABLE SET EMPTYREPORT ON
ON TABLE HOLD AS DUMMY
END


-IF 1 NE &REPORT_PART.EVAL THEN GOTO SKIPCITIZENSHIP;
-* By citizenship
TABLE FILE IQ_DW_CRM_CAMPAIGNS
SUM
     CNT.IQ_DW_CRM_CAMPAIGNS.D_CLIENTS.CLIENT_ID/D12 AS 'MEASURE'
BY  LOWEST IQ_DW_CRM_CAMPAIGNS.D_CLIENTS.CITIZENSHIP_CODE2 AS 'DIMENSION'
BY TOTAL LOWEST COMPUTE DIMENSION_GROUP/A20 = 'By Citizenship';
BY TOTAL LOWEST COMPUTE ORDER/I1=1;
WHERE SEND_DATE_FROM GE '&DATE_FROM';
WHERE SEND_DATE_FROM LE '&DATE_TO';
WHERE OPEN_DATE NE MISSING;
WHERE CAMPAIGN_TYPE_CODE EQ &CAMPAIGN_TYPE;
WHERE TEMPLATE_NAME EQ &TEMPLATE_NAME;
WHERE CAMPAIGN_NAME EQ &CAMPAIGN;
ON TABLE HOLD AS CITIZENSHIP
END
-SKIPCITIZENSHIP

-IF 2 NE &REPORT_PART.EVAL THEN GOTO SKIPGENDER;
-* By gender
TABLE FILE IQ_DW_CRM_CAMPAIGNS
SUM
     CNT.IQ_DW_CRM_CAMPAIGNS.D_CLIENTS.CLIENT_ID/D12 AS 'MEASURE'
BY  LOWEST IQ_DW_CRM_CAMPAIGNS.D_CLIENTS.GENDER_DESC2 AS 'DIMENSION'
BY TOTAL LOWEST COMPUTE DIMENSION_GROUP/A20 = 'By Gender';
BY TOTAL LOWEST COMPUTE ORDER/I1=2;
WHERE SEND_DATE_FROM GE '&DATE_FROM';
WHERE SEND_DATE_FROM LE '&DATE_TO';
WHERE OPEN_DATE NE MISSING;
WHERE CAMPAIGN_TYPE_CODE EQ &CAMPAIGN_TYPE;
WHERE TEMPLATE_NAME EQ &TEMPLATE_NAME;
WHERE CAMPAIGN_NAME EQ &CAMPAIGN;
ON TABLE HOLD AS GENDER
END
-SKIPGENDER
-* By AGE GROUP
-IF 3 NE &REPORT_PART.EVAL THEN GOTO SKIPAGEGROUP;
TABLE FILE IQ_DW_CRM_CAMPAIGNS
SUM
     CNT.IQ_DW_CRM_CAMPAIGNS.D_CLIENTS.CLIENT_ID/D12 AS 'MEASURE'
BY  LOWEST IQ_DW_CRM_CAMPAIGNS.D_CLIENTS.AGE_GROUP_ORDER2 AS 'DIMENSION'
BY TOTAL LOWEST COMPUTE DIMENSION_GROUP/A20 = 'By Age Group';
BY TOTAL LOWEST COMPUTE ORDER/I1=3;
WHERE SEND_DATE_FROM GE '&DATE_FROM';
WHERE SEND_DATE_FROM LE '&DATE_TO';
WHERE OPEN_DATE NE MISSING;
WHERE CAMPAIGN_TYPE_CODE EQ &CAMPAIGN_TYPE;
WHERE TEMPLATE_NAME EQ &TEMPLATE_NAME;
WHERE CAMPAIGN_NAME EQ &CAMPAIGN;
ON TABLE HOLD AS AGE_GROUP
END
-SKIPAGEGROUP

-* By cLUB TIER lEVEL
-IF 4 NE &REPORT_PART.EVAL THEN GOTO SKIPCLUBTIER;
TABLE FILE IQ_DW_CRM_CAMPAIGNS
SUM
     CNT.IQ_DW_CRM_CAMPAIGNS.D_CLIENTS.CLIENT_ID/D12 AS 'MEASURE'
BY  LOWEST IQ_DW_CRM_CAMPAIGNS.D_CLIENTS.CLUB_TIER_LEVEL2 AS 'DIMENSION'
BY TOTAL LOWEST COMPUTE DIMENSION_GROUP/A20 = 'By Tier Level';
BY TOTAL LOWEST COMPUTE ORDER/I1=4;
WHERE SEND_DATE_FROM GE '&DATE_FROM';
WHERE SEND_DATE_FROM LE '&DATE_TO';
WHERE OPEN_DATE NE MISSING;
WHERE CAMPAIGN_TYPE_CODE EQ &CAMPAIGN_TYPE;
WHERE TEMPLATE_NAME EQ &TEMPLATE_NAME;
WHERE CAMPAIGN_NAME EQ &CAMPAIGN;
ON TABLE HOLD AS CLUB_TIER_LEVEL
END
-SKIPCLUBTIER

-* By Total, By Campaign, By Template Name, By Market Area, By Campaign
-*-IF 5 NE &REPORT_PART.EVAL THEN GOTO SKIPCAMPAIGN
-*TABLE FILE IQ_DW_CRM_CAMPAIGNS
-*SUM
-*     CNT.IQ_DW_CRM_CAMPAIGNS.D_CLIENTS.CLIENT_ID/D12 AS 'MEASURE'
-*BY  LOWEST IQ_DW_CRM_CAMPAIGNS.D_CLIENTS.CAMPAIGN2 AS 'DIMENSION'
-*BY TOTAL LOWEST COMPUTE DIMENSION_GROUP/A20 = 'By Campaign';
-*BY TOTAL LOWEST COMPUTE ORDER/I1=5;
-*WHERE SEND_DATE_TO GE '&DATE_FROM';
-*WHERE SEND_DATE_FROM LE '&DATE_TO';
-*WHERE CAMPAIGN_TYPE_CODE EQ &CAMPAIGN_TYPE;
-*WHERE TEMPLATE_NAME EQ &TEMPLATE_NAME;
-*WHERE CAMPAIGN_NAME EQ &CAMPAIGN;
-*ON TABLE HOLD AS CAMPAIGN
-*-SKIPCAMPAIGN

-*-IF 6 NE &REPORT_PART.EVAL THEN GOTO SKIPTEMPLATENAME
-*TABLE FILE IQ_DW_CRM_CAMPAIGNS
-*SUM
-*     CNT.IQ_DW_CRM_CAMPAIGNS.D_CLIENTS.CLIENT_ID/D12 AS 'MEASURE'
-*BY  LOWEST IQ_DW_CRM_CAMPAIGNS.D_CLIENTS.TEMPLATE_NAME2 AS 'DIMENSION'
-*BY TOTAL LOWEST COMPUTE DIMENSION_GROUP/A20 = 'By Template Name';
-*BY TOTAL LOWEST COMPUTE ORDER/I1=6;
-*WHERE SEND_DATE_TO GE '&DATE_FROM';
-*WHERE SEND_DATE_FROM LE '&DATE_TO';
-*WHERE CAMPAIGN_TYPE_CODE EQ &CAMPAIGN_TYPE;
-*WHERE TEMPLATE_NAME EQ &TEMPLATE_NAME;
-*WHERE CAMPAIGN_NAME EQ &CAMPAIGN;
-*ON TABLE HOLD AS TEMPLAT_ENAME
-*-SKIPTEMPLATENAME

-*-IF 7 NE &REPORT_PART.EVAL THEN GOTO SKIPMARKETAREA
-*TABLE FILE IQ_DW_CRM_CAMPAIGNS
-*SUM
-*     CNT.IQ_DW_CRM_CAMPAIGNS.D_CLIENTS.CLIENT_ID/D12 AS 'MEASURE'
-*BY  LOWEST IQ_DW_CRM_CAMPAIGNS.D_CLIENTS.MARKET_AREA2 AS 'DIMENSION'
-*BY TOTAL LOWEST COMPUTE DIMENSION_GROUP/A20 = 'By Market Area';
-*BY TOTAL LOWEST COMPUTE ORDER/I1=7;
-*WHERE SEND_DATE_TO GE '&DATE_FROM';
-*WHERE SEND_DATE_FROM LE '&DATE_TO';
-*WHERE CAMPAIGN_TYPE_CODE EQ &CAMPAIGN_TYPE;
-*WHERE TEMPLATE_NAME EQ &TEMPLATE_NAME;
-*WHERE CAMPAIGN_NAME EQ &CAMPAIGN;
-*ON TABLE HOLD AS MARKETAREA
-*-SKIPMARKETAREA

TABLE FILE DUMMY
SUM
     MEASURE AS ''
     PCT.MEASURE/D12.2%  WITHIN DIMENSION_GROUP AS ''
BY  ORDER NOPRINT
BY  DIMENSION_GROUP NOPRINT
BY  DIMENSION AS ''

ON DIMENSION_GROUP SUBHEAD
"<DIMENSION_GROUP"
ON DIMENSION_GROUP SUBTOTAL AS 'Total'
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
     INCLUDE = IBFS:/WFC/Repository/Public/tallink_theme.sty,
$
TYPE=REPORT,
     LINES-PER-PAGE=UNLIMITED,
$
-* SIIA KIRJUTA DRILLDOWN parameetrid.

TYPE=DATA, COLUMN=DIMENSION, TARGET='_blank',
FOCEXEC=Repository/CRM/Campaign_Statistics/Campaign_header/silverpop_detail.fex ( \
DIMENSION=DIMENSION \
TEMPLATE_NAME=&TEMPLATE_NAME.QUOTEDSTRING \
CAMPAIGN=&CAMPAIGN.QUOTEDSTRING \
CAMPAIGN_TYPE=&CAMPAIGN_TYPE.QUOTEDSTRING \
DATE_FROM=&DATE_FROM.QUOTEDSTRING \
DATE_TO=&DATE_TO.QUOTEDSTRING \
REPORT_PART=ORDER \
OPEN_DATE=1 \
),
$


ENDSTYLE
-IF 1 NE &REPORT_PART.EVAL THEN GOTO SKIPCITIZENSHIP2;
MORE
FILE CITIZENSHIP
-SKIPCITIZENSHIP2
-IF 2 NE &REPORT_PART.EVAL THEN GOTO SKIPGENDER2;
MORE
FILE GENDER
-SKIPGENDER2
-IF 3 NE &REPORT_PART.EVAL THEN GOTO SKIPAGEGROUP2;
MORE
FILE AGE_GROUP
-SKIPAGEGROUP2
-IF 4 NE &REPORT_PART.EVAL THEN GOTO SKIPCLUBTIER2;
MORE
FILE CLUB_TIER_LEVEL
-SKIPCLUBTIER2
-*-IF 5 NE &REPORT_PART.EVAL THEN GOTO SKIPCAMPAIGN2;
-*FILE CAMPAIGN
-*MORE
-*-SKIPCAMPAIGN2
-*-IF 6 NE &REPORT_PART.EVAL THEN GOTO SKIPTEMPLATENAME2;
-*FILE TEMPLATE_NAME
-*MORE
-*-SKIPTEMPLATENAME2
-*IF 7 NE &REPORT_PART.EVAL THEN GOTO SKIPMARKETAREA2;
-*FILE MARKET_AREA
-*MORE
-*-SKIPMARKETAREA2
END
4

1 回答 1

0

我使用 SQLOUT 来执行此操作。以下代码执行此操作:

-SET &ECHO=ALL;
-INCLUDE general_settings.fex

-DEFAULT &DATE_FROM='2015-12-01';
-DEFAULT &DATE_TO='2015-12-05';
-TYPE &DATE_FROM
-SET &CAMPAIGN_TYPE = &CAMPAIGN_TYPE.(OR(FIND CAMPAIGN_TYPE_CODE, CAMPAIGN_TYPE_NAME IN IQ_DW_F_CRM_CAMPAIGN_HEADER)).Campaign Type.;
-SET &TEMPLATE_NAME = &TEMPLATE_NAME.(OR(FIND TEMPLATE_NAME, TEMPLATE_NAME IN IQ_DW_F_CRM_CAMPAIGN_HEADER)).Template Name.;
-SET &CAMPAIGN = &CAMPAING.(OR(FIND CAMPAIGN_NAME, CAMPAIGN_NAME IN IQ_DW_F_CRM_CAMPAIGN_HEADER)). Campaign.;
-SET &CAMPAIGN_TYPE = IF &CAMPAIGN_TYPE EQ _FOC_NULL THEN '' ELSE 'and CAMPAIGN_TYPE_CODE in(' | STRREP(&CAMPAIGN_TYPE.LENGTH,&CAMPAIGN_TYPE,4,' OR ',1,',', &CAMPAIGN_TYPE.LENGTH, '&CAMPAIGN_TYPE.LENGTH') | ')';
-SET &TEMPLATE_NAME = IF &TEMPLATE_NAME EQ _FOC_NULL THEN '' ELSE 'and TEMPLATE_NAME in(' | STRREP(&TEMPLATE_NAME.LENGTH,&TEMPLATE_NAME,4,' OR ',1,',', &TEMPLATE_NAME.LENGTH, '&TEMPLATE_NAME.LENGTH') | ')';
-SET &CAMPAIGN = IF &CAMPAIGN EQ _FOC_NULL THEN '' ELSE 'and CAMPAIGN_NAME in(' | STRREP(&CAMPAIGN.LENGTH,&CAMPAIGN,4,' OR ',1,',', &CAMPAIGN.LENGTH, '&CAMPAIGN.LENGTH') | ')';


ENGINE SQLSYB SET DEFAULT_CONNECTION ait
SQL SQLSYB PREPARE SQLOUT FOR
SELECT NUMBER_OF_SENT_EMAILS, COUNT(*) AS NUMBER_OF_CLIENT_IDS
FROM (
SELECT MEL.CLIENT_ID, COUNT(*) AS NUMBER_OF_SENT_EMAILS
      FROM DW.F_CRM_CAMPAIGN_HEADER MEL
        WHERE SEND_DATE_FROM <='&DATE_TO'
        AND SEND_DATE_TO >='&DATE_FROM'
      GROUP BY MEL.CLIENT_ID

     ) A
GROUP BY NUMBER_OF_SENT_EMAILS
END
TABLE FILE SQLOUT
PRINT *
BY NUMBER_OF_SENT_EMAILS NOPRINT

ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
     INCLUDE = theme.sty,
$
TYPE=REPORT,
     LINES-PER-PAGE=UNLIMITED,
$
ENDSTYLE
END
于 2016-02-29T11:08:30.027 回答