CRM合同转SAP订单

insert into ZVBAK(ZCRMID,ZOPERA,ZSYSTY,ZDATE1,ZTIME1,DOC_TYPE,BUKRS,SALES_ORG,DIVISION,SALES_OFF,SALES_GRP,PSPID,PURCH_NO_C,PURCH_DATE,REQ_DATE_H,
PMNTTRMS,
BILL_BLOCK,
ZFLAG,
CFLAG,
MANDT,
TYPE_GROUP,
DISTR_CHAN

)
values(${entity.FId},1,2,TO_CHAR(now(),'YYYYMMDD'),TO_CHAR(now(),'HHMMSS'),'ZS01',
(select FCompanyId from TsDepartment
where FId=${entity.FSalesDepartmentId}),
(select FVkOrg from TuSalesOppt where FId=${entity.FSalesOpptId}),
(select FIndustry from TuSalesOppt where FId=${entity.FSalesOpptId}),
(select FVkbur from TuSalesOppt where FId=${entity.FSalesOpptId}),
(select FVkgrp from TuSalesOppt where FId=${entity.FSalesOpptId}),
(select FName from TuSalesOppt where FId=${entity.FSalesOpptId}),
(select FName from TuSalesOppt where FId=${entity.FSalesOpptId}),
TO_CHAR(now(),'YYYYMMDD'),
TO_CHAR(now(),'YYYYMMDD'),
'D000',
'Z1',
0,
0,
810,
1,
'01'
);


insert into ZVBPA(ZCRMID,
ZOPERA,
ZSYSTY,
ZDATE1,
ZTIME1,
MANDT,
ZVBAK_CRMID,
PARTN_ROLE,
PARTN_NUMB,
TEXT_LINE,
TYPE_GROUP,
ZFLAG,
CFLAG
)VALUES(uuid(),
1,
2,
TO_CHAR(now(),'YYYYMMDD'),
TO_CHAR(now(),'HHMMSS'),
810,
${entity.FId},
'AG',
${entity.FSAPCustomerNum},
'',
1,
0,
0

);


insert into ZVBPA(ZCRMID,
ZOPERA,
ZSYSTY,
ZDATE1,
ZTIME1,
MANDT,
ZVBAK_CRMID,
PARTN_ROLE,
PARTN_NUMB,
TEXT_LINE,
TYPE_GROUP,
ZFLAG,
CFLAG
)VALUES(uuid(),
1,
2,
TO_CHAR(now(),'YYYYMMDD'),
TO_CHAR(now(),'HHMMSS'),
810,
${entity.FId},
'VE',
(select FLoginName from TsUser where FId=${entity.FSignedUserId}),
'',
1,
0,
0
);

 ZVBAP部分

insert into ZVBAP(MANDT,ZCRMID,ZOPERA,ZSYSTY,ZDATE1,ZTIME1,
ZVBAK_CRMID,
TYPE_GROUP,
REQ_QTY,
MATERIAL,
PLANT,
TARGET_QTY,
COND_TYPE,
COND_VALUE,
ZFLAG,
CFLAG
)
values
(100,
uuid(),
1,
2,
TO_CHAR(now(),'YYYYMMDD'),
TO_CHAR(now(),'HHMMSS'),
${entity.FContractId},
1,
1,
(
select 
case FAmountType
when to_nchar('现场') then 'S000003'
when to_nchar('柜台') then 'S000002'
when to_nchar('设计费') then 
(select 
  case FProperty
  when to_nchar('Design') then 'S000019'
  else 'S000001'
  end
  from TuSalesOppt where FId=(select FSalesOpptId from TcContract where FId=${entity.FContractId})
  
)
else 'S000004'

end
from TcContractDetail 
where FId='734b6013-667e-4836-a3bb-87e31969b98e'),
(
select FCompanyId from TsDepartment  where FId=(select FSalesDepartmentId from TcContract where FId=${entity.FContractId})),
1,
'ZPR0',
${entity.FAmount},
0,
0

)

 

 

posted @ 2013-05-29 17:51  方东信  阅读(372)  评论(0编辑  收藏  举报