其他分享
首页 > 其他分享> > BP主数据添加代码

BP主数据添加代码

作者:互联网

一,1.1创建函数ZSD_CREATE_BP

 

 1.2定义结构

 

 

 

 

 

 1.3导出参数

 

 二,对应的代码参数

  1 FUNCTION ZSD_CREATE_BP.
  2 *"----------------------------------------------------------------------
  3 *"*"本地接口:
  4 *"  IMPORTING
  5 *"     REFERENCE(I_BP_DATA) TYPE  ZSDS025
  6 *"  TABLES
  7 *"      ET_RETURN STRUCTURE  BAPIRET2
  8 *"----------------------------------------------------------------------
  9 
 10   DATA: GS_BP_DATA TYPE ZSDS025 .
 11   DATA: LT_RETURN TYPE TABLE OF BAPIRET2,
 12         LS_RETURN TYPE BAPIRET2.
 13   DATA: LF_PARTNER    TYPE KNA1-KUNNR,
 14         LF_BP_PARTNER TYPE KNA1-KUNNR.
 15 
 16   DATA: LF_LENTH TYPE INT4 .
 17   DATA: GF_ERR TYPE CHAR1 .
 18 
 19   CLEAR: ET_RETURN ,ET_RETURN[].
 20   CLEAR GS_BP_DATA .
 21   GS_BP_DATA = I_BP_DATA .
 22 
 23   CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
 24     EXPORTING
 25       INPUT  = GS_BP_DATA-PARTNER
 26     IMPORTING
 27       OUTPUT = GS_BP_DATA-PARTNER.
 28 
 29   CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
 30     EXPORTING
 31       INPUT  = GS_BP_DATA-AKONT
 32     IMPORTING
 33       OUTPUT = GS_BP_DATA-AKONT.
 34 
 35   IF GS_BP_DATA-KUNN2_PY IS INITIAL .
 36     CLEAR LF_LENTH .
 37     LF_LENTH = STRLEN( GS_BP_DATA-PARTNER ) .
 38     IF LF_LENTH < 17 .
 39       GS_BP_DATA-KUNN2_PY = GS_BP_DATA-PARTNER .
 40     ELSE .
 41       GS_BP_DATA-KUNN2_PY = GS_BP_DATA-PARTNER+7(10) .
 42     ENDIF .
 43   ENDIF.
 44 
 45   IF GS_BP_DATA-KUNN2_BP IS INITIAL .
 46     CLEAR LF_LENTH .
 47     LF_LENTH = STRLEN( GS_BP_DATA-PARTNER ) .
 48     IF LF_LENTH < 17 .
 49       GS_BP_DATA-KUNN2_BP = GS_BP_DATA-PARTNER .
 50     ELSE .
 51       GS_BP_DATA-KUNN2_BP = GS_BP_DATA-PARTNER+7(10) .
 52     ENDIF .
 53   ENDIF.
 54 
 55   IF GS_BP_DATA-KUNN2_SH IS INITIAL .
 56     CLEAR LF_LENTH .
 57     LF_LENTH = STRLEN( GS_BP_DATA-PARTNER ) .
 58     IF LF_LENTH < 17 .
 59       GS_BP_DATA-KUNN2_SH = GS_BP_DATA-PARTNER .
 60     ELSE .
 61       GS_BP_DATA-KUNN2_SH = GS_BP_DATA-PARTNER+7(10) .
 62     ENDIF .
 63   ENDIF.
 64 
 65   CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
 66     EXPORTING
 67       INPUT  = GS_BP_DATA-KUNN2_PY
 68     IMPORTING
 69       OUTPUT = GS_BP_DATA-KUNN2_PY.
 70   CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
 71     EXPORTING
 72       INPUT  = GS_BP_DATA-KUNN2_BP
 73     IMPORTING
 74       OUTPUT = GS_BP_DATA-KUNN2_BP.
 75   CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
 76     EXPORTING
 77       INPUT  = GS_BP_DATA-KUNN2_SH
 78     IMPORTING
 79       OUTPUT = GS_BP_DATA-KUNN2_SH.
 80 
 81   CLEAR LF_BP_PARTNER .
 82   CLEAR LF_LENTH .
 83   LF_LENTH = STRLEN( GS_BP_DATA-PARTNER ) .
 84   IF LF_LENTH < 17 .
 85     LF_BP_PARTNER = GS_BP_DATA-PARTNER .
 86   ELSE .
 87     LF_BP_PARTNER = GS_BP_DATA-PARTNER+7(10) .
 88   ENDIF .
 89 
 90 *1. 判断业务伙伴是否存在 ,存在,执行11 ,不存在,执行2
 91   CLEAR LF_PARTNER .
 92   SELECT SINGLE PARTNER INTO LF_PARTNER FROM BUT000 WHERE PARTNER = LF_BP_PARTNER .
 93   IF SY-SUBRC <> 0 .
 94 *2. 创建业务伙伴基本信息  参考ZMM_CREATE_BP-FRM_CREATE_BP
 95     CLEAR GF_ERR .
 96     PERFORM FRM_CREATE_BP TABLES ET_RETURN USING GS_BP_DATA CHANGING GF_ERR .
 97     CHECK GF_ERR <> 'X' .
 98 *3. 判断科目组是否为(1001 1002)是,执行4 ,否执行5
 99     IF GS_BP_DATA-BU_GROUP = '1001' OR GS_BP_DATA-BU_GROUP = '1002' .
100 *4. 添加角色: FLCU00  ZMM_CREATE_BP-FRM_ADD_BP_ROLE
101       CLEAR GF_ERR .
102       PERFORM FRM_ADD_BP_ROLE TABLES ET_RETURN USING GS_BP_DATA-PARTNER 'FLCU00' CHANGING GF_ERR .
103       CHECK GF_ERR <> 'X' .
104     ELSE.
105 *5. 添加角色: FLCU00  FLCU01 UKM000 ZMM_CREATE_BP-FRM_ADD_BP_ROLE
106       CLEAR GF_ERR .
107       PERFORM FRM_ADD_BP_ROLE TABLES ET_RETURN USING GS_BP_DATA-PARTNER 'FLCU00' CHANGING GF_ERR .
108       CHECK GF_ERR <> 'X' .
109 
110       CLEAR GF_ERR .
111       PERFORM FRM_ADD_BP_ROLE TABLES ET_RETURN USING GS_BP_DATA-PARTNER 'FLCU01' CHANGING GF_ERR .
112       CHECK GF_ERR <> 'X' .
113 
114       CLEAR GF_ERR .
115       PERFORM FRM_ADD_BP_ROLE TABLES ET_RETURN USING GS_BP_DATA-PARTNER 'UKM000' CHANGING GF_ERR .
116       CHECK GF_ERR <> 'X' .
117     ENDIF .
118 *6. 创建业务伙伴的税号 ZMM_CREATE_BP-FRM_TAX_CREATE
119     IF GS_BP_DATA-TAXNUMXL IS NOT INITIAL .
120       CLEAR GF_ERR .
121       PERFORM FRM_TAX_CREATE TABLES ET_RETURN USING GS_BP_DATA-PARTNER GS_BP_DATA-TAXNUMXL CHANGING GF_ERR .
122       CHECK GF_ERR <> 'X' .
123     ENDIF .
124 *7. 创建银行数据  ZMM_CREATE_BP-FRM_BANK_CREATE
125     IF GS_BP_DATA-BANKL IS NOT INITIAL .
126       CLEAR GF_ERR .
127       PERFORM FRM_BANK_CREATE TABLES ET_RETURN USING GS_BP_DATA CHANGING GF_ERR .
128     ENDIF .
129 *8. 创建公司数据  cmd_ei_api=>maintain_bapi
130     IF GS_BP_DATA-BUKRS IS NOT INITIAL .
131       PERFORM FRM_BUKRS_CREATE TABLES ET_RETURN USING GS_BP_DATA CHANGING GF_ERR.
132     ENDIF .
133 *9. 创建销售数据  cmd_ei_api=>maintain_bapi
134     IF GS_BP_DATA-VKORG IS NOT INITIAL AND
135        GS_BP_DATA-VTWEG IS NOT INITIAL AND
136        GS_BP_DATA-SPART IS NOT INITIAL.
137       PERFORM FRM_SALES_CREATE TABLES ET_RETURN USING GS_BP_DATA CHANGING GF_ERR.
138     ENDIF .
139 *10.创建信贷数据 结束
140     IF GS_BP_DATA-PARTNER IS NOT INITIAL .
141       CLEAR GF_ERR .
142       PERFORM FRM_CREDIT_CREATE TABLES ET_RETURN USING GS_BP_DATA-PARTNER GS_BP_DATA-LIMIT_RULE CHANGING GF_ERR .
143       CHECK GF_ERR <> 'X' .
144     ENDIF.
145   ELSE .
146 *11.修改业务伙伴基本信息
147     CLEAR GF_ERR .
148     PERFORM FRM_CHANGE_BP TABLES ET_RETURN USING GS_BP_DATA CHANGING GF_ERR .
149     CHECK GF_ERR <> 'X' .
150 *12.判断科目组是否为(1001 1002)是,执行13 ,否执行14
151     IF GS_BP_DATA-BU_GROUP = '1001' AND GS_BP_DATA-BU_GROUP = '1002' .
152 *13 判断角色是否存在: FLCU00 ,不存在则添加
153       CLEAR LF_PARTNER .
154       SELECT SINGLE PARTNER INTO LF_PARTNER FROM BUT100 WHERE PARTNER = LF_BP_PARTNER AND RLTYP = 'FLVN00' .
155       IF SY-SUBRC <> 0 .
156         CLEAR GF_ERR .
157         PERFORM FRM_ADD_BP_ROLE TABLES ET_RETURN USING GS_BP_DATA-PARTNER 'FLCU00' CHANGING GF_ERR .
158         CHECK GF_ERR <> 'X' .
159       ENDIF .
160     ELSE.
161 *14.修改业务伙伴的税号
162       IF GS_BP_DATA-TAXNUMXL IS NOT INITIAL .
163         CLEAR LF_PARTNER .
164         SELECT SINGLE PARTNER INTO LF_PARTNER FROM DFKKBPTAXNUM WHERE PARTNER = LF_BP_PARTNER AND TAXTYPE = 'CN0' .
165         IF SY-SUBRC <> 0 .
166           CLEAR GF_ERR .
167           PERFORM FRM_TAX_CREATE TABLES ET_RETURN  USING GS_BP_DATA-PARTNER GS_BP_DATA-TAXNUMXL CHANGING GF_ERR .
168           CHECK GF_ERR <> 'X' .
169         ELSE .
170           CLEAR GF_ERR .
171           PERFORM FRM_TAX_CHANGE TABLES ET_RETURN  USING GS_BP_DATA-PARTNER GS_BP_DATA-TAXNUMXL CHANGING GF_ERR.
172           CHECK GF_ERR <> 'X' .
173         ENDIF .
174       ENDIF .
175     ENDIF .
176 *15.修改银行数据
177     DATA: LF_BANKN1    TYPE BUT0BK-BANKN,
178           LF_BANKN2    TYPE BUT0BK-KOINH,
179           LF_STR_LENTH TYPE I,
180           LF_BKVID     TYPE BUT0BK-BKVID.
181     IF GS_BP_DATA-BANKL IS NOT INITIAL .
182       CLEAR: LF_BANKN1 ,LF_BANKN2 ,LF_STR_LENTH .
183       LF_STR_LENTH = STRLEN( GS_BP_DATA-BANKN ) .
184       IF LF_STR_LENTH <= 18 .
185         LF_BANKN1 = GS_BP_DATA-BANKN .
186         LF_BANKN2 = SPACE .
187       ELSE .
188         LF_BANKN1 = GS_BP_DATA-BANKN+0(18) .
189         LF_BANKN2 = GS_BP_DATA-BANKN+18 .
190       ENDIF .
191 
192       CLEAR LF_BKVID .
193       SELECT SINGLE BKVID INTO LF_BKVID FROM BUT0BK
194         WHERE PARTNER = LF_BP_PARTNER .
195       IF SY-SUBRC <> 0 .
196         CLEAR GF_ERR .
197         PERFORM FRM_BANK_CREATE TABLES ET_RETURN  USING GS_BP_DATA CHANGING GF_ERR .
198         CHECK GF_ERR <> 'X' .
199       ELSE .
200         CLEAR GF_ERR .
201         PERFORM FRM_BANK_CHANGE TABLES ET_RETURN USING GS_BP_DATA  LF_BKVID CHANGING GF_ERR.
202         CHECK GF_ERR <> 'X' .
203       ENDIF .
204     ENDIF .
205 *16.修改公司数据 cmd_ei_api=>maintain_bapi
206     IF GS_BP_DATA-BUKRS IS NOT INITIAL .
207       CLEAR LF_PARTNER .
208       SELECT SINGLE KUNNR INTO LF_PARTNER FROM KNB1
209         WHERE BUKRS = GS_BP_DATA-BUKRS AND
210               KUNNR = LF_BP_PARTNER .
211       IF SY-SUBRC <> 0 .
212         PERFORM FRM_BUKRS_CREATE TABLES ET_RETURN USING GS_BP_DATA CHANGING GF_ERR.
213       ELSE .
214         PERFORM FRM_BUKRS_CHANGE TABLES ET_RETURN  USING GS_BP_DATA CHANGING GF_ERR.
215       ENDIF .
216     ENDIF .
217 *17.修改销售数据 cmd_ei_api=>maintain_bapi
218     IF GS_BP_DATA-VKORG IS NOT INITIAL AND
219        GS_BP_DATA-VTWEG IS NOT INITIAL AND
220        GS_BP_DATA-SPART IS NOT INITIAL.
221       CLEAR LF_PARTNER .
222       SELECT SINGLE KUNNR INTO LF_PARTNER FROM KNVV WHERE KUNNR = LF_BP_PARTNER AND
223                                                           VKORG = GS_BP_DATA-VKORG AND
224                                                           VTWEG = GS_BP_DATA-VTWEG AND
225                                                           SPART = GS_BP_DATA-SPART.
226       IF SY-SUBRC <> 0 .
227         PERFORM FRM_SALES_CREATE TABLES ET_RETURN USING GS_BP_DATA CHANGING GF_ERR.
228       ELSE .
229         PERFORM FRM_SALES_CHANGE TABLES ET_RETURN USING GS_BP_DATA CHANGING GF_ERR.
230       ENDIF .
231     ENDIF .
232 *18.修改信贷数据 结束
233     IF GS_BP_DATA-LIMIT_RULE IS NOT INITIAL .
234       CLEAR LF_PARTNER .
235       SELECT SINGLE PARTNER FROM UKMBP_CMS INTO LF_PARTNER WHERE PARTNER = LF_BP_PARTNER AND
236                                                                  LIMIT_RULE = GS_BP_DATA-LIMIT_RULE.
237       IF SY-SUBRC <> 0.
238         CLEAR GF_ERR .
239         PERFORM FRM_CREDIT_CREATE TABLES ET_RETURN USING GS_BP_DATA-PARTNER GS_BP_DATA-LIMIT_RULE CHANGING GF_ERR .
240         CHECK GF_ERR <> 'X' .
241       ELSE .
242         CLEAR GF_ERR .
243         PERFORM FRM_CREDIT_CHANGE TABLES ET_RETURN USING GS_BP_DATA-PARTNER GS_BP_DATA-LIMIT_RULE CHANGING GF_ERR .
244         CHECK GF_ERR <> 'X' .
245       ENDIF.
246     ENDIF.
247   ENDIF.
248 
249   CLEAR GS_BP_DATA .
250 
251 ENDFUNCTION.
View Code

 

标签:GS,ERR,代码,GF,添加,BP,PARTNER,DATA
来源: https://www.cnblogs.com/yushuiguodong/p/15034712.html