//--线条 //3-----点击文字特效---

一,1.1创建函数ZSD_CREATE_BP

 

 1.2定义结构

 

 

 

 

 

 1.3导出参数

 1.4,选择已经创建函数组

 

 

 

 

 

 

 二,对应的代码参数

  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

 三,对应form代码

   1    1 *----------------------------------------------------------------------*
   2    2 ***INCLUDE LZSD002F01.
   3    3 *----------------------------------------------------------------------*
   4    4 *&---------------------------------------------------------------------*
   5    5 *& Form FRM_CREATE_BP
   6    6 *&---------------------------------------------------------------------*
   7    7 *& text
   8    8 *&---------------------------------------------------------------------*
   9    9 *      -->P_EFT_RETURN  text
  10   10 *      -->P_GS_BP_DATA  text
  11   11 *      <--P_GF_ERR  text
  12   12 *&---------------------------------------------------------------------*
  13   13 FORM FRM_CREATE_BP  TABLES       FT_RETURN STRUCTURE BAPIRET2
  14   14                     USING  VALUE(FS_BP_DATA) TYPE ZSDS025
  15   15                     CHANGING     FC_ERR TYPE CHAR1 .
  16   16 
  17   17   DATA: LF_CITY_CODE TYPE ADRCITYT-CITY_CODE.
  18   18   DATA: LF_STRT_CODE TYPE ADRSTREETT-STRT_CODE.
  19   19   DATA: LS_CENTRAL       TYPE BAPIBUS1006_CENTRAL,                 "一般 BP 数据,与业务伙伴类别无关
  20   20         LS_CENTRAL_ORGAN TYPE BAPIBUS1006_CENTRAL_ORGAN,           "SAP BP: 组织数据的 BAPI 结构
  21   21         LS_ADDRESS       TYPE BAPIBUS1006_ADDRESS,                 "SAP BP: 地址数据的 BAPI 结构
  22   22 
  23   23         LT_BAPIADTEL     TYPE TABLE OF BAPIADTEL  , "电话号码的 BAPI 结构(办公地址服务)
  24   24         LS_BAPIADTEL     TYPE BAPIADTEL,
  25   25 
  26   26         LT_BAPIADFAX     TYPE TABLE OF BAPIADFAX  , "传真号码的 BAPI 结构(办公地址服务))
  27   27         LS_BAPIADFAX     TYPE BAPIADFAX,
  28   28 
  29   29         LFT_RETURN       TYPE BUS_BAPIRET2_T   , "返回参数
  30   30         LS_RETURN        TYPE BAPIRET2,
  31   31 
  32   32         LS_GUID          TYPE BUS000___I,                          "CBP: 一般数据和状态信息
  33   33         LS_CUSTO         TYPE BUS000_EEW,                          "SAP BP: 传输用于 CI 包括 BP 扩展的结构
  34   34         LFT_RETURN_TAX   TYPE BUS_BAPIRET2_T.
  35   35 
  36   36   DATA: LF_PARTNER TYPE BUT000-PARTNER .
  37   37   DATA: LF_STRLEN TYPE I .
  38   38   CLEAR: LFT_RETURN , LFT_RETURN[] .
  39   39   CLEAR: FC_ERR.
  40   40 
  41   41   LS_CENTRAL-TITLE_KEY       = FS_BP_DATA-TITLE . " 标题
  42   42   LS_CENTRAL_ORGAN-NAME1     = FS_BP_DATA-NAME_ORG1 . " 供应商名称
  43   43   LS_CENTRAL_ORGAN-NAME4    = FS_BP_DATA-INTERNAL_ORGANIZATION . " 经销商届数
  44   44   LS_CENTRAL-SEARCHTERM1     = FS_BP_DATA-BU_SORT1  . " 搜索项1
  45   45   "  LS_ADDRESS-STREET          = FS_BP_DATA-STREET . " 地址
  46   46   LS_ADDRESS-COUNTRY         = FS_BP_DATA-LAND1 . " 国家
  47   47   LS_ADDRESS-REGION          = FS_BP_DATA-REGION  . " 地区(省
  48   48 
  49   49   CLEAR: LF_STRLEN .
  50   50   LF_STRLEN = STRLEN( FS_BP_DATA-CITY1 ) .
  51   51   IF LF_STRLEN <= 12.
  52   52     CLEAR LF_CITY_CODE .
  53   53     CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  54   54       EXPORTING
  55   55         INPUT  = FS_BP_DATA-CITY1
  56   56       IMPORTING
  57   57         OUTPUT = LF_CITY_CODE.
  58   58     SELECT SINGLE CITY_NAME INTO LS_ADDRESS-CITY FROM ADRCITYT WHERE CITY_CODE = LF_CITY_CODE AND COUNTRY = 'CN'.
  59   59     IF SY-SUBRC <> 0 .
  60   60       LS_ADDRESS-CITY            = FS_BP_DATA-CITY1  . " 城市
  61   61     ENDIF .
  62   62   ELSE.
  63   63     LS_ADDRESS-CITY            = FS_BP_DATA-CITY1  . " 城市
  64   64   ENDIF.
  65   65 
  66   66   LS_ADDRESS-COUNTY_NO = FS_BP_DATA-POST_CODE1 .
  67   67 
  68   68   CLEAR:LF_STRLEN .
  69   69   LF_STRLEN = STRLEN( FS_BP_DATA-STR_SUPPL1 ) .
  70   70 
  71   71   IF LF_STRLEN <= 12 .
  72   72     CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  73   73       EXPORTING
  74   74         INPUT  = FS_BP_DATA-STR_SUPPL1
  75   75       IMPORTING
  76   76         OUTPUT = LF_STRT_CODE.
  77   77     SELECT SINGLE STREET INTO LS_ADDRESS-STR_SUPPL1 FROM ADRSTREETT WHERE STRT_CODE = LF_STRT_CODE AND COUNTRY = 'CN'.
  78   78     IF SY-SUBRC <> 0 .
  79   79       LS_ADDRESS-STR_SUPPL1 = FS_BP_DATA-STR_SUPPL1 .
  80   80     ENDIF.
  81   81   ELSE.
  82   82     LS_ADDRESS-STR_SUPPL1 = FS_BP_DATA-STR_SUPPL1 .
  83   83   ENDIF.
  84   84 
  85   85   LS_ADDRESS-STREET       = FS_BP_DATA-STREET .
  86   86 *  SELECT SINGLE STREET INTO LS_ADDRESS-STR_SUPPL1  FROM ADRSTREETT WHERE STRT_CODE = LF_STRT_CODE AND COUNTRY = 'CN'.
  87   87 *  LS_ADDRESS-STREET      = FS_BP_DATA-STR_SUPPL1.
  88   88 
  89   89   LS_ADDRESS-STR_SUPPL2      = FS_BP_DATA-STR_SUPPL2.
  90   90   LS_ADDRESS-POSTL_COD1      = FS_BP_DATA-POST_CODE1 . " 邮政编码
  91   91   LS_ADDRESS-LANGU           = FS_BP_DATA-LANGU . " 语言
  92   92 
  93   93 
  94   94   LS_BAPIADTEL-TELEPHONE = FS_BP_DATA-TEL_NUMBER1 . " 电话
  95   95   APPEND LS_BAPIADTEL TO LT_BAPIADTEL.
  96   96   CLEAR LS_BAPIADTEL.
  97   97 
  98   98   LS_BAPIADTEL-R_3_USER  = '2'.         "标识符:电话是移动电话
  99   99   LS_BAPIADTEL-TELEPHONE = FS_BP_DATA-MOB_NUMBER . " 移动电话
 100  100   APPEND LS_BAPIADTEL TO LT_BAPIADTEL.
 101  101   CLEAR LS_BAPIADTEL.
 102  102 
 103  103   CLEAR LT_BAPIADFAX.
 104  104   LS_BAPIADFAX-FAX       = FS_BP_DATA-TEL_NUMBER1 . " 电话
 105  105   APPEND LS_BAPIADTEL TO LT_BAPIADFAX.
 106  106   CLEAR LS_BAPIADTEL.
 107  107 
 108  108   CLEAR LF_PARTNER .
 109  109   DATA: LF_LENTH TYPE INT4 .
 110  110   CLEAR LF_LENTH .
 111  111   LF_LENTH = STRLEN( FS_BP_DATA-PARTNER ) .
 112  112   IF LF_LENTH < 17 .
 113  113     LF_PARTNER = FS_BP_DATA-PARTNER .
 114  114   ELSE .
 115  115     LF_PARTNER = FS_BP_DATA-PARTNER+7(10) .
 116  116   ENDIF .
 117  117 
 118  118   CALL FUNCTION 'BAPI_BUPA_CREATE_FROM_DATA'
 119  119     EXPORTING
 120  120       BUSINESSPARTNEREXTERN   = LF_PARTNER  "业务伙伴编码
 121  121       PARTNERCATEGORY         = '2'                  "业务伙伴类别
 122  122       PARTNERGROUP            = FS_BP_DATA-BU_GROUP "业务伙伴分组
 123  123       CENTRALDATA             = LS_CENTRAL
 124  124       CENTRALDATAORGANIZATION = LS_CENTRAL_ORGAN
 125  125       ADDRESSDATA             = LS_ADDRESS
 126  126     IMPORTING
 127  127       BUSINESSPARTNER         = LF_PARTNER
 128  128     TABLES
 129  129       TELEFONDATA             = LT_BAPIADTEL
 130  130       FAXDATA                 = LT_BAPIADFAX
 131  131       RETURN                  = LFT_RETURN.
 132  132 
 133  133   DELETE LFT_RETURN WHERE TYPE <> 'A' AND TYPE <> 'E' .
 134  134   LOOP AT LFT_RETURN INTO LS_RETURN WHERE TYPE = 'A'
 135  135                    OR    TYPE = 'E'.
 136  136     FC_ERR = 'X'.
 137  137     EXIT.
 138  138   ENDLOOP.
 139  139   IF FC_ERR = 'X'.
 140  140     APPEND LINES OF LFT_RETURN TO FT_RETURN .
 141  141     RETURN.
 142  142   ENDIF.
 143  143 
 144  144 
 145  145   CALL FUNCTION 'BUP_MEMORY_BUT000_GET'
 146  146     EXPORTING
 147  147       IV_PARTNER       = LF_PARTNER
 148  148     IMPORTING
 149  149       ES_BUT000        = LS_GUID
 150  150     EXCEPTIONS
 151  151       NOT_FOUND        = 1
 152  152       PARAMETER_ERROR  = 2
 153  153       BPEXT_NOT_UNIQUE = 3
 154  154       OTHERS           = 4.
 155  155   IF SY-SUBRC <> 0.
 156  156     FC_ERR = 'X'.
 157  157     RETURN.
 158  158   ENDIF.
 159  159 
 160  160   LS_CUSTO-PARTNR_GUID = LS_GUID-PARTNER_GUID."业务伙伴全局唯一标识符
 161  161 
 162  162   CLEAR LFT_RETURN[].
 163  163   CALL FUNCTION 'BUPA_CENTRAL_CI_CHANGE'
 164  164     EXPORTING
 165  165       IS_BUS000_EEW = LS_CUSTO
 166  166     IMPORTING
 167  167       ET_RETURN     = LFT_RETURN.
 168  168 
 169  169   DELETE LFT_RETURN WHERE TYPE <> 'A' AND TYPE <> 'E' .
 170  170   LOOP AT LFT_RETURN INTO LS_RETURN WHERE TYPE = 'A'
 171  171                                      OR    TYPE = 'E'.
 172  172     FC_ERR = 'X'.
 173  173     EXIT.
 174  174   ENDLOOP.
 175  175   IF FC_ERR = 'X'.
 176  176     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
 177  177     APPEND LINES OF LFT_RETURN TO FT_RETURN .
 178  178     RETURN.
 179  179   ELSE.
 180  180     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
 181  181       EXPORTING
 182  182         WAIT = 'X'.
 183  183   ENDIF.
 184  184 ENDFORM.
 185  185 *&---------------------------------------------------------------------*
 186  186 *& Form FRM_ADD_BP_ROLE
 187  187 *&---------------------------------------------------------------------*
 188  188 *& text
 189  189 *&---------------------------------------------------------------------*
 190  190 *      -->P_EFT_RETURN  text
 191  191 *      -->P_GS_BP_DATA_PARTNER  text
 192  192 *      -->P_       text
 193  193 *      <--P_GF_ERR  text
 194  194 *&---------------------------------------------------------------------*
 195  195 FORM FRM_ADD_BP_ROLE  TABLES   FT_RETURN STRUCTURE BAPIRET2
 196  196                       USING VALUE(FU_PARTNER) TYPE ZSDS025-PARTNER
 197  197                             VALUE(FU_ROLE)    TYPE BAPIBUS1006_BPROLES-PARTNERROLE
 198  198                       CHANGING  FC_ERR TYPE CHAR1 .
 199  199 
 200  200   DATA: LFT_RETURN TYPE BUS_BAPIRET2_T   , "返回参数
 201  201         LS_RETURN  TYPE BAPIRET2.
 202  202   DATA: LF_PARTNER TYPE BUT000-PARTNER .
 203  203   CLEAR:  LFT_RETURN , LFT_RETURN[] .
 204  204   CLEAR: FC_ERR.
 205  205 
 206  206   CLEAR LF_PARTNER .
 207  207   DATA: LF_LENTH TYPE INT4 .
 208  208   CLEAR LF_LENTH .
 209  209   LF_LENTH = STRLEN( FU_PARTNER ) .
 210  210   IF LF_LENTH < 17 .
 211  211     LF_PARTNER = FU_PARTNER .
 212  212   ELSE .
 213  213     LF_PARTNER = FU_PARTNER+7(10) .
 214  214   ENDIF .
 215  215 
 216  216   CALL FUNCTION 'BAPI_BUPA_ROLE_ADD_2'
 217  217     EXPORTING
 218  218       BUSINESSPARTNER             = LF_PARTNER
 219  219       BUSINESSPARTNERROLECATEGORY = FU_ROLE
 220  220       BUSINESSPARTNERROLE         = FU_ROLE
 221  221     TABLES
 222  222       RETURN                      = LFT_RETURN.
 223  223 
 224  224   DELETE LFT_RETURN WHERE TYPE <> 'A' AND TYPE <> 'E' .
 225  225   LOOP AT LFT_RETURN INTO LS_RETURN WHERE TYPE = 'A'
 226  226                     OR    TYPE = 'E'.
 227  227     FC_ERR = 'X'.
 228  228     EXIT.
 229  229   ENDLOOP.
 230  230 
 231  231   IF FC_ERR = 'X'.
 232  232     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
 233  233     APPEND LINES OF LFT_RETURN TO FT_RETURN .
 234  234     RETURN.
 235  235   ELSE.
 236  236     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
 237  237       EXPORTING
 238  238         WAIT = 'X'.
 239  239   ENDIF .
 240  240 ENDFORM.
 241  241 *&---------------------------------------------------------------------*
 242  242 *& Form FRM_TAX_CREATE
 243  243 *&---------------------------------------------------------------------*
 244  244 *& text
 245  245 *&---------------------------------------------------------------------*
 246  246 *      -->P_EFT_RETURN  text
 247  247 *      -->P_GS_BP_DATA_PARTNER  text
 248  248 *      -->P_GS_BP_DATA_TAXNUMXL  text
 249  249 *      <--P_GF_ERR  text
 250  250 *&---------------------------------------------------------------------*
 251  251 FORM FRM_TAX_CREATE  TABLES   FT_RETURN STRUCTURE BAPIRET2
 252  252                      USING VALUE(FU_PARTNER)  TYPE ZSDS025-PARTNER
 253  253                            VALUE(FU_TAXNUMXL) TYPE ZSDS025-TAXNUMXL
 254  254                      CHANGING  FC_ERR TYPE CHAR1 .
 255  255 
 256  256   DATA: LFT_RETURN TYPE BUS_BAPIRET2_T   , "返回参数
 257  257         LS_RETURN  TYPE BAPIRET2.
 258  258   DATA: LF_PARTNER  TYPE BUT000-PARTNER,
 259  259         LF_TAXNUMXL TYPE DFKKBPTAXNUM-TAXNUM.
 260  260   CLEAR: LFT_RETURN , LFT_RETURN[] .
 261  261 
 262  262   CLEAR: LF_PARTNER ,LF_TAXNUMXL.
 263  263   DATA: LF_LENTH TYPE INT4 .
 264  264   CLEAR LF_LENTH .
 265  265   LF_LENTH = STRLEN( FU_PARTNER ) .
 266  266   IF LF_LENTH < 17 .
 267  267     LF_PARTNER = FU_PARTNER .
 268  268   ELSE .
 269  269     LF_PARTNER = FU_PARTNER+7(10) .
 270  270   ENDIF .
 271  271   LF_TAXNUMXL = FU_TAXNUMXL.
 272  272   CALL FUNCTION 'BAPI_BUPA_TAX_ADD'
 273  273     EXPORTING
 274  274       BUSINESSPARTNER = LF_PARTNER
 275  275       TAXTYPE         = 'CN0'
 276  276       TAXNUMBER       = LF_TAXNUMXL
 277  277     TABLES
 278  278       RETURN          = LFT_RETURN.
 279  279 
 280  280   DELETE LFT_RETURN WHERE TYPE <> 'A' AND TYPE <> 'E' .
 281  281   LOOP AT LFT_RETURN INTO LS_RETURN WHERE TYPE = 'A'
 282  282                      OR    TYPE = 'E'.
 283  283     FC_ERR = 'X'.
 284  284     EXIT.
 285  285   ENDLOOP.
 286  286 
 287  287   IF FC_ERR = 'X'.
 288  288     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
 289  289     APPEND LINES OF LFT_RETURN TO FT_RETURN .
 290  290     RETURN.
 291  291   ELSE.
 292  292     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
 293  293       EXPORTING
 294  294         WAIT = 'X'.
 295  295   ENDIF.
 296  296 
 297  297 ENDFORM.
 298  298 *&---------------------------------------------------------------------*
 299  299 *& Form FRM_BANK_CREATE
 300  300 *&---------------------------------------------------------------------*
 301  301 *& text
 302  302 *&---------------------------------------------------------------------*
 303  303 *      -->P_EFT_RETURN  text
 304  304 *      -->P_GS_BP_DATA  text
 305  305 *      <--P_GF_ERR  text
 306  306 *&---------------------------------------------------------------------*
 307  307 FORM FRM_BANK_CREATE  TABLES   FT_RETURN STRUCTURE BAPIRET2
 308  308                       USING  VALUE(FS_BP_DATA) TYPE ZSDS025
 309  309                       CHANGING     FC_ERR TYPE CHAR1 .
 310  310 
 311  311   DATA: LF_PARTENR TYPE BUT000-PARTNER .
 312  312   DATA: LS_BANKDETAILDATA TYPE BAPIBUS1006_BANKDETAIL.
 313  313   DATA: LS_BANKDETAILDATAX TYPE BAPIBUS1006_BANKDETAIL_X.
 314  314   DATA: LFT_RETURN TYPE BUS_BAPIRET2_T   , "返回参数
 315  315         LS_RETURN  TYPE BAPIRET2.
 316  316 
 317  317 *  EKP          = SAP
 318  318 *  银行所在国家 = 国家[BUT0BK-BANKS]  BANKS
 319  319 *  户名         = 帐户名称[BUT0BK-ACCNAME]  KOINH
 320  320 *  开户行账户   = 银行帐号[BUT0BK-BANKN] + 帐户持有人[BUT0BK-KOINH]
 321  321 *  银行名称     = 银行名称【自动带出】
 322  322 *  银行代码     = 银行代码[BUT0BK-BANKL] BANKL
 323  323 
 324  324   DATA: LF_STR_LENTH TYPE I .
 325  325   CLEAR LF_STR_LENTH .
 326  326   LF_STR_LENTH = STRLEN( FS_BP_DATA-BANKN ) .
 327  327   CLEAR LS_BANKDETAILDATA .
 328  328   LS_BANKDETAILDATA-BANK_CTRY         = FS_BP_DATA-BANKS.    "银行国家
 329  329   LS_BANKDETAILDATA-BANKACCOUNTNAME   = FS_BP_DATA-ACCNAME.    "帐户名称
 330  330   IF LF_STR_LENTH <= 18 .
 331  331     LS_BANKDETAILDATA-BANK_ACCT         = FS_BP_DATA-BANKN. " 银行帐户
 332  332     LS_BANKDETAILDATA-BANK_REF     = SPACE .    "" 参考明细--作为银行帐户后18位
 333  333   ELSE .
 334  334     LS_BANKDETAILDATA-BANK_ACCT         = FS_BP_DATA-BANKN+0(18). " 银行帐户
 335  335     LS_BANKDETAILDATA-BANK_REF     = FS_BP_DATA-BANKN+18 .    " 参考明细--作为银行帐户后18位
 336  336   ENDIF .
 337  337   LS_BANKDETAILDATA-BANK_KEY          = FS_BP_DATA-BANKL.    "银行代码
 338  338 *  LS_BANKDETAILDATA-ACCOUNTHOLDER      = FS_BP_DATA-BUKRS.   " 账户持有人-- 作为公司代码使用
 339  339 
 340  340   CLEAR LF_PARTENR .
 341  341   DATA: LF_LENTH TYPE INT4 .
 342  342   CLEAR LF_LENTH .
 343  343   LF_LENTH = STRLEN( FS_BP_DATA-PARTNER ) .
 344  344   IF LF_LENTH < 17 .
 345  345     LF_PARTENR = FS_BP_DATA-PARTNER .
 346  346   ELSE .
 347  347     LF_PARTENR = FS_BP_DATA-PARTNER+7(10) .
 348  348   ENDIF .
 349  349 
 350  350   CALL FUNCTION 'BAPI_BUPA_BANKDETAIL_ADD'
 351  351     EXPORTING
 352  352       BUSINESSPARTNER = LF_PARTENR
 353  353       BANKDETAILDATA  = LS_BANKDETAILDATA
 354  354     TABLES
 355  355       RETURN          = LFT_RETURN.
 356  356   DELETE LFT_RETURN WHERE TYPE <> 'A' AND TYPE <> 'E' .
 357  357   LOOP AT LFT_RETURN INTO LS_RETURN WHERE TYPE = 'A'
 358  358                     OR    TYPE = 'E'.
 359  359     FC_ERR = 'X'.
 360  360     EXIT.
 361  361   ENDLOOP.
 362  362 
 363  363   IF FC_ERR = 'X'.
 364  364     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
 365  365     APPEND LINES OF LFT_RETURN TO FT_RETURN .
 366  366     RETURN.
 367  367   ELSE.
 368  368     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
 369  369       EXPORTING
 370  370         WAIT = 'X'.
 371  371   ENDIF.
 372  372 ENDFORM.
 373  373 *&---------------------------------------------------------------------*
 374  374 *& Form FRM_CHANGE_BP
 375  375 *&---------------------------------------------------------------------*
 376  376 *& text
 377  377 *&---------------------------------------------------------------------*
 378  378 *      -->P_EFT_RETURN  text
 379  379 *      -->P_GS_BP_DATA  text
 380  380 *      <--P_GF_ERR  text
 381  381 *&---------------------------------------------------------------------*
 382  382 FORM FRM_CHANGE_BP  TABLES   FT_RETURN STRUCTURE BAPIRET2
 383  383                     USING    VALUE(FS_BP_DATA) TYPE ZSDS025
 384  384                     CHANGING  FC_ERR TYPE CHAR1 .
 385  385 
 386  386   DATA LF_CITY_CODE TYPE ADRCITYT-CITY_CODE .
 387  387   DATA LF_STRT_CODE TYPE ADRSTREETT-STRT_CODE.
 388  388   DATA: LS_CENTRAL         TYPE BAPIBUS1006_CENTRAL,                 "一般 BP 数据,与业务伙伴类别无关
 389  389         LS_CENTRAL_X       TYPE BAPIBUS1006_CENTRAL_X,
 390  390         LS_CENTRAL_ORGAN   TYPE BAPIBUS1006_CENTRAL_ORGAN,           "SAP BP: 组织数据的 BAPI 结构
 391  391         LS_CENTRAL_ORGAN_X TYPE BAPIBUS1006_CENTRAL_ORGAN_X,
 392  392         LS_ADDRESS         TYPE BAPIBUS1006_ADDRESS,                 "SAP BP: 地址数据的 BAPI 结构
 393  393         LS_ADDRESS_X       TYPE BAPIBUS1006_ADDRESS_X,                 "SAP BP: 地址数据的 BAPI 结构
 394  394 
 395  395         LT_BAPIADTEL       TYPE TABLE OF BAPIADTEL  , "电话号码的 BAPI 结构(办公地址服务)
 396  396         LT_BAPIADTEL_X     TYPE TABLE OF BAPIADTELX,
 397  397         LS_BAPIADTEL       TYPE BAPIADTEL,
 398  398         LS_BAPIADTEL_X     TYPE BAPIADTELX,
 399  399 
 400  400         LT_BAPIADFAX       TYPE TABLE OF BAPIADFAX  , "传真号码的 BAPI 结构(办公地址服务))
 401  401         LT_BAPIADFAX_X     TYPE TABLE OF BAPIADFAXX,
 402  402         LS_BAPIADFAX       TYPE BAPIADFAX,
 403  403         LS_BAPIADFAX_X     TYPE BAPIADFAXX,
 404  404 
 405  405         LFT_RETURN         TYPE BUS_BAPIRET2_T   , "返回参数
 406  406         LS_RETURN          TYPE BAPIRET2,
 407  407 
 408  408         LS_GUID            TYPE BUS000___I,                          "CBP: 一般数据和状态信息
 409  409         LS_CUSTO           TYPE BUS000_EEW,                          "SAP BP: 传输用于 CI 包括 BP 扩展的结构
 410  410         LFT_RETURN_TAX     TYPE BUS_BAPIRET2_T.
 411  411   DATA: LF_STRLEN TYPE I .
 412  412 
 413  413   DATA: LF_PARTNER TYPE BUT000-PARTNER .
 414  414   CLEAR:  LFT_RETURN , LFT_RETURN[] .
 415  415   CLEAR: FC_ERR.
 416  416 
 417  417   CLEAR: LS_CENTRAL ,LS_CENTRAL_X .
 418  418   LS_CENTRAL-TITLE_KEY       = FS_BP_DATA-TITLE . " 标题
 419  419   LS_CENTRAL_ORGAN-NAME1     = FS_BP_DATA-NAME_ORG1 . " 供应商名称
 420  420   LS_CENTRAL_ORGAN-NAME4    = FS_BP_DATA-INTERNAL_ORGANIZATION . " 经销商届数
 421  421   LS_CENTRAL_ORGAN_X-NAME1   = 'X' .
 422  422   LS_CENTRAL-SEARCHTERM1     = FS_BP_DATA-BU_SORT1  . " 搜索项1
 423  423   LS_CENTRAL_X-SEARCHTERM1   = 'X' .
 424  424   "  LS_ADDRESS-STREET          = FS_BP_DATA-STREET . " 地址
 425  425   LS_ADDRESS-COUNTRY         = FS_BP_DATA-LAND1 . " 国家
 426  426   LS_ADDRESS-REGION          = FS_BP_DATA-REGION  . " 地区(省
 427  427   CLEAR LF_CITY_CODE .
 428  428   LF_STRLEN = STRLEN( FS_BP_DATA-CITY1 ) .
 429  429   IF LF_STRLEN <= 12 .
 430  430     CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
 431  431       EXPORTING
 432  432         INPUT  = FS_BP_DATA-CITY1
 433  433       IMPORTING
 434  434         OUTPUT = LF_CITY_CODE.
 435  435     SELECT SINGLE CITY_NAME INTO LS_ADDRESS-CITY FROM ADRCITYT WHERE CITY_CODE = LF_CITY_CODE AND COUNTRY = 'CN'.
 436  436     IF SY-SUBRC <> 0 .
 437  437       LS_ADDRESS-CITY            = FS_BP_DATA-CITY1  . " 城市
 438  438     ENDIF .
 439  439   ELSE.
 440  440     LS_ADDRESS-CITY            = FS_BP_DATA-CITY1  . " 城市
 441  441   ENDIF.
 442  442 
 443  443   LS_ADDRESS-COUNTY_NO = FS_BP_DATA-POST_CODE1 .
 444  444 
 445  445   CLEAR LF_STRLEN .
 446  446   LF_STRLEN = STRLEN( FS_BP_DATA-STR_SUPPL1 ) .
 447  447   IF LF_STRLEN <= 12 .
 448  448     CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
 449  449       EXPORTING
 450  450         INPUT  = FS_BP_DATA-STR_SUPPL1
 451  451       IMPORTING
 452  452         OUTPUT = LF_STRT_CODE.
 453  453     SELECT SINGLE STREET INTO LS_ADDRESS-STR_SUPPL1 FROM ADRSTREETT WHERE STRT_CODE = LF_STRT_CODE AND COUNTRY = 'CN'.
 454  454     IF SY-SUBRC <> 0 .
 455  455       LS_ADDRESS-STR_SUPPL1 = FS_BP_DATA-STR_SUPPL1 .
 456  456     ENDIF.
 457  457   ELSE.
 458  458     LS_ADDRESS-STR_SUPPL1 = FS_BP_DATA-STR_SUPPL1 .
 459  459   ENDIF .
 460  460 
 461  461 
 462  462   LS_ADDRESS-STREET       = FS_BP_DATA-STREET .
 463  463 *  SELECT SINGLE STREET INTO LS_ADDRESS-STR_SUPPL1 FROM ADRSTREETT WHERE STRT_CODE = LF_STRT_CODE AND COUNTRY = 'CN'.
 464  464 *  LS_ADDRESS-STREET      = FS_BP_DATA-STR_SUPPL1.
 465  465 
 466  466   LS_ADDRESS-STR_SUPPL2      = FS_BP_DATA-STR_SUPPL2.
 467  467   LS_ADDRESS-POSTL_COD1      = FS_BP_DATA-POST_CODE1 . " 邮政编码
 468  468   LS_ADDRESS-LANGU           = FS_BP_DATA-LANGU . " 语言
 469  469 
 470  470   CLEAR: LS_ADDRESS_X .
 471  471   LS_ADDRESS_X-STREET          = 'X' . " 地址
 472  472   LS_ADDRESS_X-COUNTRY         = 'X' . " 国家
 473  473   LS_ADDRESS_X-REGION          = 'X'  . " 地区(省
 474  474   LS_ADDRESS_X-CITY            = 'X'  . " 城市
 475  475   LS_ADDRESS_X-POSTL_COD1      = 'X' . " 邮政编码
 476  476   LS_ADDRESS_X-COUNTY_NO       = 'X'.
 477  477   LS_ADDRESS_X-STR_SUPPL1      = 'X'.
 478  478   LS_ADDRESS_X-STR_SUPPL2      = 'X'.
 479  479   LS_ADDRESS_X-LANGU           = 'X' . " 语言
 480  480 
 481  481   CLEAR: LT_BAPIADTEL ,LT_BAPIADTEL[] .
 482  482   LS_BAPIADTEL-TELEPHONE = FS_BP_DATA-TEL_NUMBER1 . " 电话
 483  483   APPEND LS_BAPIADTEL TO LT_BAPIADTEL.
 484  484   CLEAR LS_BAPIADTEL.
 485  485   LS_BAPIADTEL-R_3_USER  = '2'.         "标识符:电话是移动电话
 486  486   LS_BAPIADTEL-TELEPHONE = FS_BP_DATA-MOB_NUMBER . " 移动电话
 487  487   APPEND LS_BAPIADTEL TO LT_BAPIADTEL.
 488  488   CLEAR LS_BAPIADTEL.
 489  489 
 490  490   CLEAR: LT_BAPIADTEL_X ,LT_BAPIADTEL_X[] .
 491  491   LS_BAPIADTEL_X-TELEPHONE = 'X' . " 电话
 492  492   APPEND LS_BAPIADTEL_X TO LT_BAPIADTEL_X.
 493  493   CLEAR LS_BAPIADTEL_X.
 494  494   LS_BAPIADTEL_X-R_3_USER  = '2'.         "标识符:电话是移动电话
 495  495   LS_BAPIADTEL_X-TELEPHONE = 'X'  . " 移动电话
 496  496   APPEND LS_BAPIADTEL_X TO LT_BAPIADTEL_X.
 497  497   CLEAR LS_BAPIADTEL_X.
 498  498 
 499  499   CLEAR: LT_BAPIADFAX ,LT_BAPIADFAX[].
 500  500   LS_BAPIADFAX-FAX       = FS_BP_DATA-TEL_NUMBER1 . " 电话
 501  501   APPEND LS_BAPIADTEL TO LT_BAPIADFAX.
 502  502   CLEAR LS_BAPIADTEL.
 503  503 
 504  504   CLEAR: LT_BAPIADFAX_X ,LT_BAPIADFAX_X[].
 505  505   LS_BAPIADFAX_X-FAX       = FS_BP_DATA-TEL_NUMBER1 . " 电话
 506  506   APPEND LS_BAPIADTEL_X TO LT_BAPIADFAX_X.
 507  507   CLEAR LS_BAPIADTEL_X.
 508  508 
 509  509   CLEAR LF_PARTNER .
 510  510   DATA LF_LENTH TYPE INT4 .
 511  511   CLEAR LF_LENTH .
 512  512   LF_LENTH = STRLEN( FS_BP_DATA-PARTNER ) .
 513  513   IF LF_LENTH < 17 .
 514  514     LF_PARTNER = FS_BP_DATA-PARTNER .
 515  515   ELSE .
 516  516     LF_PARTNER = FS_BP_DATA-PARTNER+7(10) .
 517  517   ENDIF .
 518  518 
 519  519   CALL FUNCTION 'BAPI_BUPA_CENTRAL_CHANGE'
 520  520     EXPORTING
 521  521       BUSINESSPARTNER           = LF_PARTNER
 522  522       CENTRALDATA               = LS_CENTRAL
 523  523       CENTRALDATAORGANIZATION   = LS_CENTRAL_ORGAN
 524  524       CENTRALDATA_X             = LS_CENTRAL_X
 525  525       CENTRALDATAORGANIZATION_X = LS_CENTRAL_ORGAN_X
 526  526 *     DUPLICATE_CHECK_ADDRESS   = LS_ADDRESS
 527  527     TABLES
 528  528 *     TELEFONDATANONADDRESS     = LT_BAPIADTEL
 529  529 *     FAXDATANONADDRESS         = LT_BAPIADFAX
 530  530       RETURN                    = LFT_RETURN.
 531  531 
 532  532 
 533  533   DELETE LFT_RETURN WHERE TYPE <> 'A' AND TYPE <> 'E' .
 534  534   LOOP AT LFT_RETURN INTO LS_RETURN WHERE TYPE = 'A'
 535  535                    OR    TYPE = 'E'.
 536  536     FC_ERR = 'X'.
 537  537     EXIT.
 538  538   ENDLOOP.
 539  539 
 540  540   IF FC_ERR = 'X'.
 541  541     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
 542  542     APPEND LINES OF LFT_RETURN TO FT_RETURN .
 543  543     RETURN.
 544  544   ELSE.
 545  545     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
 546  546       EXPORTING
 547  547         WAIT = 'X'.
 548  548   ENDIF.
 549  549 
 550  550   CLEAR: LFT_RETURN ,LFT_RETURN[] .
 551  551   CALL FUNCTION 'BAPI_BUPA_ADDRESS_CHANGE'
 552  552     EXPORTING
 553  553       BUSINESSPARTNER = LF_PARTNER
 554  554       ADDRESSDATA     = LS_ADDRESS
 555  555       ADDRESSDATA_X   = LS_ADDRESS_X
 556  556     TABLES
 557  557       BAPIADTEL       = LT_BAPIADTEL
 558  558       BAPIADFAX       = LT_BAPIADFAX
 559  559       BAPIADTEL_X     = LT_BAPIADTEL_X
 560  560       BAPIADFAX_X     = LT_BAPIADFAX_X
 561  561       RETURN          = LFT_RETURN.
 562  562   DELETE LFT_RETURN WHERE TYPE <> 'A' AND TYPE <> 'E' .
 563  563   LOOP AT LFT_RETURN INTO LS_RETURN WHERE TYPE = 'A'
 564  564                    OR    TYPE = 'E'.
 565  565     FC_ERR = 'X'.
 566  566     EXIT.
 567  567   ENDLOOP.
 568  568 
 569  569   IF FC_ERR = 'X'.
 570  570     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
 571  571     APPEND LINES OF LFT_RETURN TO FT_RETURN .
 572  572     RETURN.
 573  573   ELSE.
 574  574     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
 575  575       EXPORTING
 576  576         WAIT = 'X'.
 577  577   ENDIF.
 578  578 ENDFORM.
 579  579 *&---------------------------------------------------------------------*
 580  580 *& Form FRM_TAX_CHANGE
 581  581 *&---------------------------------------------------------------------*
 582  582 *& text
 583  583 *&---------------------------------------------------------------------*
 584  584 *      -->P_EFT_RETURN  text
 585  585 *      -->P_GS_BP_DATA_PARTNER  text
 586  586 *      -->P_GS_BP_DATA_TAXNUMXL  text
 587  587 *      <--P_GF_ERR  text
 588  588 *&---------------------------------------------------------------------*
 589  589 FORM FRM_TAX_CHANGE  TABLES  FT_RETURN STRUCTURE BAPIRET2
 590  590                      USING VALUE(FU_PARTNER)  TYPE ZSDS025-PARTNER
 591  591                            VALUE(FU_TAXNUMXL) TYPE ZSDS025-TAXNUMXL
 592  592                      CHANGING  FC_ERR TYPE CHAR1 .
 593  593 
 594  594   DATA: LF_PARTNER  TYPE BUT000-PARTNER,
 595  595         LF_TAXNUMXL TYPE DFKKBPTAXNUM-TAXNUM.
 596  596   DATA: LFT_RETURN TYPE BUS_BAPIRET2_T   , "返回参数
 597  597         LS_RETURN  TYPE BAPIRET2.
 598  598   CLEAR:  LFT_RETURN , LFT_RETURN[] .
 599  599   CLEAR: FC_ERR.
 600  600 
 601  601   CLEAR: LF_PARTNER ,LF_TAXNUMXL .
 602  602   DATA: LF_LENTH TYPE INT4 .
 603  603   CLEAR LF_LENTH .
 604  604   LF_LENTH = STRLEN( FU_PARTNER ) .
 605  605   IF LF_LENTH < 17 .
 606  606     LF_PARTNER = FU_PARTNER .
 607  607   ELSE .
 608  608     LF_PARTNER = FU_PARTNER+7(10) .
 609  609   ENDIF .
 610  610 
 611  611   LF_TAXNUMXL = FU_TAXNUMXL .
 612  612   CALL FUNCTION 'BAPI_BUPA_TAX_CHANGE'
 613  613     EXPORTING
 614  614       BUSINESSPARTNER = LF_PARTNER
 615  615       TAXTYPE         = 'CN0'
 616  616       TAXNUMBER       = LF_TAXNUMXL
 617  617     TABLES
 618  618       RETURN          = LFT_RETURN.
 619  619 
 620  620   DELETE LFT_RETURN WHERE TYPE <> 'A' AND TYPE <> 'E' .
 621  621   LOOP AT LFT_RETURN INTO LS_RETURN WHERE TYPE = 'A'
 622  622                    OR    TYPE = 'E'.
 623  623     FC_ERR = 'X'.
 624  624     EXIT.
 625  625   ENDLOOP.
 626  626 
 627  627   IF FC_ERR = 'X'.
 628  628     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
 629  629     APPEND LINES OF LFT_RETURN TO FT_RETURN .
 630  630     RETURN.
 631  631   ELSE.
 632  632     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
 633  633       EXPORTING
 634  634         WAIT = 'X'.
 635  635   ENDIF .
 636  636 ENDFORM.
 637  637 *&---------------------------------------------------------------------*
 638  638 *& Form FRM_BANK_CHANGE
 639  639 *&---------------------------------------------------------------------*
 640  640 *& text
 641  641 *&---------------------------------------------------------------------*
 642  642 *      -->P_EFT_RETURN  text
 643  643 *      -->P_GS_BP_DATA  text
 644  644 *      -->P_LF_BKVID  text
 645  645 *      <--P_GF_ERR  text
 646  646 *&---------------------------------------------------------------------*
 647  647 FORM FRM_BANK_CHANGE  TABLES  FT_RETURN STRUCTURE BAPIRET2
 648  648                       USING   VALUE(FS_BP_DATA) TYPE ZSDS025
 649  649                               VALUE(FU_BKVID) TYPE BUT0BK-BKVID
 650  650                       CHANGING  FC_ERR TYPE CHAR1 .
 651  651 
 652  652   DATA: LS_BANKDETAILDATA TYPE BAPIBUS1006_BANKDETAIL.
 653  653   DATA: LS_BANKDETAILDATAX TYPE BAPIBUS1006_BANKDETAIL_X.
 654  654   DATA: LFT_RETURN TYPE BUS_BAPIRET2_T   , "返回参数
 655  655         LS_RETURN  TYPE BAPIRET2.
 656  656   DATA: LF_PARTNER TYPE BUT000-PARTNER .
 657  657 
 658  658   CLEAR: LS_BANKDETAILDATA ,LS_BANKDETAILDATAX .
 659  659 
 660  660   DATA: LF_STR_LENTH TYPE I .
 661  661   CLEAR LF_STR_LENTH .
 662  662   LF_STR_LENTH = STRLEN( FS_BP_DATA-BANKN ) .
 663  663   LS_BANKDETAILDATA-BANK_CTRY         = FS_BP_DATA-BANKS.    "银行国家
 664  664   LS_BANKDETAILDATA-BANKACCOUNTNAME   = FS_BP_DATA-ACCNAME.    "帐户名称
 665  665   IF LF_STR_LENTH <= 18 .
 666  666     LS_BANKDETAILDATA-BANK_ACCT         = FS_BP_DATA-BANKN. " 银行帐户
 667  667     LS_BANKDETAILDATA-BANK_REF     = SPACE .    " 参考明细--作为银行帐户后18位
 668  668   ELSE .
 669  669     LS_BANKDETAILDATA-BANK_ACCT         = FS_BP_DATA-BANKN+0(18). " 银行帐户
 670  670     LS_BANKDETAILDATA-BANK_REF     = FS_BP_DATA-BANKN+18.    " 参考明细--作为银行帐户后18位
 671  671   ENDIF .
 672  672   LS_BANKDETAILDATA-BANK_KEY          = FS_BP_DATA-BANKL.    "银行代码
 673  673 *  LS_BANKDETAILDATA-ACCOUNTHOLDER      = FS_BP_DATA-BUKRS.   " 账户持有人-- 作为公司代码使用
 674  674 
 675  675   LS_BANKDETAILDATAX-BANKACCOUNTNAME   = 'X'.
 676  676   LS_BANKDETAILDATAX-BANK_ACCT         = 'X'.
 677  677   LS_BANKDETAILDATAX-ACCOUNTHOLDER     = 'X'.
 678  678   LS_BANKDETAILDATAX-BANK_KEY          = 'X'.
 679  679   LS_BANKDETAILDATAX-BANK_REF          = 'X'.
 680  680 
 681  681   CLEAR LF_PARTNER .
 682  682   DATA: LF_LENTH TYPE INT4 .
 683  683   CLEAR LF_LENTH .
 684  684   LF_LENTH = STRLEN( FS_BP_DATA-PARTNER ) .
 685  685   IF LF_LENTH < 17 .
 686  686     LF_PARTNER = FS_BP_DATA-PARTNER .
 687  687   ELSE .
 688  688     LF_PARTNER = FS_BP_DATA-PARTNER+7(10) .
 689  689   ENDIF .
 690  690 
 691  691   CALL FUNCTION 'BAPI_BUPA_BANKDETAIL_CHANGE'
 692  692     EXPORTING
 693  693       BUSINESSPARTNER  = LF_PARTNER
 694  694       BANKDETAILID     = FU_BKVID
 695  695       BANKDETAILDATA   = LS_BANKDETAILDATA
 696  696       BANKDETAILDATA_X = LS_BANKDETAILDATAX
 697  697     TABLES
 698  698       RETURN           = LFT_RETURN.
 699  699   DELETE LFT_RETURN WHERE TYPE <> 'A' AND TYPE <> 'E' .
 700  700   LOOP AT LFT_RETURN INTO LS_RETURN WHERE TYPE = 'A'
 701  701                     OR    TYPE = 'E'.
 702  702     FC_ERR = 'X'.
 703  703     EXIT.
 704  704   ENDLOOP.
 705  705 
 706  706   IF FC_ERR = 'X'.
 707  707     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
 708  708     APPEND LINES OF LFT_RETURN TO FT_RETURN .
 709  709     RETURN.
 710  710   ELSE.
 711  711     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
 712  712       EXPORTING
 713  713         WAIT = 'X'.
 714  714   ENDIF.
 715  715 ENDFORM.
 716  716 *&---------------------------------------------------------------------*
 717  717 *& Form FRM_BUKRS_CHANGE
 718  718 *&---------------------------------------------------------------------*
 719  719 *& text
 720  720 *&---------------------------------------------------------------------*
 721  721 *      -->P_EFT_RETURN  text
 722  722 *      -->P_GS_BP_DATA  text
 723  723 *&---------------------------------------------------------------------*
 724  724 FORM FRM_BUKRS_CHANGE  TABLES   FT_RETURN STRUCTURE BAPIRET2
 725  725                        USING    VALUE(FS_BP_DATA) TYPE ZSDS025
 726  726                        CHANGING  FC_ERR TYPE CHAR1 .
 727  727 
 728  728   DATA: LS_COMPANY TYPE CMDS_EI_COMPANY,     "外部接口:公司代码数据
 729  729         LT_COMPANY TYPE CMDS_EI_COMPANY_T.   "外部接口:公司代码数据
 730  730   DATA: LS_CMDS_EXTERN   TYPE CMDS_EI_MAIN,  "外部接口:总计客户数据
 731  731         LS_SUCC_MESSAGES TYPE CVIS_MESSAGE,
 732  732         LS_CMDS_ERROR    TYPE CMDS_EI_MAIN,
 733  733         LS_ERR_MESSAGES  TYPE CVIS_MESSAGE,
 734  734         LS_RETURN        TYPE BAPIRET2,
 735  735         LS_CMDS_SUCC     TYPE CMDS_EI_MAIN.
 736  736 
 737  737   DATA: LS_CUSTOMERS TYPE CMDS_EI_EXTERN,    "客户的复合外部接口
 738  738         LT_CUSTOMERS TYPE CMDS_EI_EXTERN_T.  "客户的复合外部接口 (Tab.)
 739  739   CLEAR: LT_COMPANY ,LT_COMPANY[].
 740  740   CLEAR: LS_CUSTOMERS , LT_CUSTOMERS ,LT_CUSTOMERS[] .
 741  741   CLEAR: LS_CMDS_EXTERN  ,
 742  742          LS_SUCC_MESSAGES ,
 743  743          LS_CMDS_ERROR   ,
 744  744          LS_ERR_MESSAGES ,
 745  745          LS_CMDS_SUCC .
 746  746 
 747  747   DATA: LF_PARTNER TYPE KNA1-KUNNR .
 748  748   DATA: LF_LENTH TYPE INT4 .
 749  749   CLEAR LF_LENTH .
 750  750   LF_LENTH = STRLEN( FS_BP_DATA-PARTNER ) .
 751  751   IF LF_LENTH < 17 .
 752  752     LF_PARTNER = FS_BP_DATA-PARTNER .
 753  753   ELSE .
 754  754     LF_PARTNER = FS_BP_DATA-PARTNER+7(10) .
 755  755   ENDIF .
 756  756 
 757  757   LS_CUSTOMERS-HEADER-OBJECT_TASK = 'U'.
 758  758   LS_CUSTOMERS-HEADER-OBJECT_INSTANCE-KUNNR = LF_PARTNER ."
 759  759 
 760  760   LS_COMPANY-TASK = 'U'.
 761  761   LS_COMPANY-DATA_KEY-BUKRS  = FS_BP_DATA-BUKRS . " 公司代码
 762  762   LS_COMPANY-DATA-AKONT      = FS_BP_DATA-AKONT . " 统驭科目
 763  763   LS_COMPANY-DATA-ZUAWA      = '031' . " 排序码
 764  764   LS_COMPANY-DATA-ZTERM      = FS_BP_DATA-ZTERM . " 付款条件
 765  765   LS_COMPANY-DATAX-AKONT     = 'X'.
 766  766   LS_COMPANY-DATAX-ZUAWA     = 'X'.
 767  767   LS_COMPANY-DATAX-ZTERM     = 'X'.
 768  768   APPEND LS_COMPANY TO LT_COMPANY.
 769  769   CLEAR LS_COMPANY.
 770  770   LS_CUSTOMERS-COMPANY_DATA-COMPANY[] = LT_COMPANY[].
 771  771   APPEND LS_CUSTOMERS TO LT_CUSTOMERS .
 772  772   CLEAR LS_CUSTOMERS .
 773  773 
 774  774   LS_CMDS_EXTERN-CUSTOMERS = LT_CUSTOMERS[].
 775  775   CMD_EI_API=>INITIALIZE( ).
 776  776   CALL METHOD CMD_EI_API=>MAINTAIN_BAPI
 777  777     EXPORTING
 778  778       IS_MASTER_DATA           = LS_CMDS_EXTERN
 779  779     IMPORTING
 780  780       ES_MASTER_DATA_CORRECT   = LS_CMDS_SUCC
 781  781       ES_MESSAGE_CORRECT       = LS_SUCC_MESSAGES
 782  782       ES_MASTER_DATA_DEFECTIVE = LS_CMDS_ERROR
 783  783       ES_MESSAGE_DEFECTIVE     = LS_ERR_MESSAGES.
 784  784 
 785  785   LOOP AT LS_ERR_MESSAGES-MESSAGES INTO LS_RETURN WHERE TYPE = 'A'
 786  786                     OR    TYPE = 'E'.
 787  787     FC_ERR = 'X'.
 788  788     EXIT.
 789  789   ENDLOOP.
 790  790 
 791  791   IF FC_ERR = 'X'.
 792  792     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
 793  793     APPEND LINES OF LS_ERR_MESSAGES-MESSAGES TO FT_RETURN .
 794  794     RETURN.
 795  795   ELSE.
 796  796     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
 797  797       EXPORTING
 798  798         WAIT = 'X'.
 799  799   ENDIF.
 800  800 
 801  801 ENDFORM.
 802  802 *&---------------------------------------------------------------------*
 803  803 *& Form FRM_BUKRS_CREATE
 804  804 *&---------------------------------------------------------------------*
 805  805 *& text
 806  806 *&---------------------------------------------------------------------*
 807  807 *      -->P_EFT_RETURN  text
 808  808 *      -->P_GS_BP_DATA  text
 809  809 *&---------------------------------------------------------------------*
 810  810 FORM FRM_BUKRS_CREATE  TABLES   FT_RETURN STRUCTURE BAPIRET2
 811  811                        USING    VALUE(FS_BP_DATA) TYPE ZSDS025
 812  812                        CHANGING  FC_ERR TYPE CHAR1 .
 813  813 
 814  814   DATA: LS_COMPANY TYPE CMDS_EI_COMPANY,     "外部接口:公司代码数据
 815  815         LT_COMPANY TYPE CMDS_EI_COMPANY_T.   "外部接口:公司代码数据
 816  816   DATA: LS_CMDS_EXTERN   TYPE CMDS_EI_MAIN,  "外部接口:总计客户数据
 817  817         LS_SUCC_MESSAGES TYPE CVIS_MESSAGE,
 818  818         LS_CMDS_ERROR    TYPE CMDS_EI_MAIN,
 819  819         LS_ERR_MESSAGES  TYPE CVIS_MESSAGE,
 820  820         LS_RETURN        TYPE BAPIRET2,
 821  821         LS_CMDS_SUCC     TYPE CMDS_EI_MAIN.
 822  822 
 823  823   DATA: LS_CUSTOMERS TYPE CMDS_EI_EXTERN,    "客户的复合外部接口
 824  824         LT_CUSTOMERS TYPE CMDS_EI_EXTERN_T.  "客户的复合外部接口 (Tab.)
 825  825   CLEAR: LT_COMPANY ,LT_COMPANY[].
 826  826   CLEAR: LS_CUSTOMERS , LT_CUSTOMERS ,LT_CUSTOMERS[] .
 827  827   CLEAR: LS_CMDS_EXTERN  ,
 828  828          LS_SUCC_MESSAGES ,
 829  829          LS_CMDS_ERROR   ,
 830  830          LS_ERR_MESSAGES ,
 831  831          LS_CMDS_SUCC .
 832  832 
 833  833   DATA: LF_PARTNER TYPE KNA1-KUNNR .
 834  834   DATA: LF_LENTH TYPE INT4 .
 835  835   CLEAR LF_LENTH .
 836  836   LF_LENTH = STRLEN( FS_BP_DATA-PARTNER ) .
 837  837   IF LF_LENTH < 17 .
 838  838     LF_PARTNER = FS_BP_DATA-PARTNER .
 839  839   ELSE .
 840  840     LF_PARTNER = FS_BP_DATA-PARTNER+7(10) .
 841  841   ENDIF .
 842  842 
 843  843   LS_CUSTOMERS-HEADER-OBJECT_TASK = 'U'.
 844  844   LS_CUSTOMERS-HEADER-OBJECT_INSTANCE-KUNNR = LF_PARTNER ."
 845  845 
 846  846   LS_COMPANY-TASK = 'I'.
 847  847   LS_COMPANY-DATA_KEY-BUKRS  = FS_BP_DATA-BUKRS . " 公司代码
 848  848   LS_COMPANY-DATA-AKONT      = FS_BP_DATA-AKONT . " 统驭科目
 849  849   LS_COMPANY-DATA-ZUAWA      = '031' . " 排序码
 850  850   LS_COMPANY-DATA-ZTERM      = FS_BP_DATA-ZTERM . " 付款条件
 851  851   LS_COMPANY-DATAX-AKONT     = 'X'.
 852  852   LS_COMPANY-DATAX-ZUAWA     = 'X'.
 853  853   LS_COMPANY-DATAX-ZTERM     = 'X'.
 854  854   APPEND LS_COMPANY TO LT_COMPANY.
 855  855   CLEAR LS_COMPANY.
 856  856   LS_CUSTOMERS-COMPANY_DATA-COMPANY[] = LT_COMPANY[].
 857  857   APPEND LS_CUSTOMERS TO LT_CUSTOMERS .
 858  858   CLEAR LS_CUSTOMERS .
 859  859 
 860  860   LS_CMDS_EXTERN-CUSTOMERS = LT_CUSTOMERS[].
 861  861   CMD_EI_API=>INITIALIZE( ).
 862  862   CALL METHOD CMD_EI_API=>MAINTAIN_BAPI
 863  863     EXPORTING
 864  864       IS_MASTER_DATA           = LS_CMDS_EXTERN
 865  865     IMPORTING
 866  866       ES_MASTER_DATA_CORRECT   = LS_CMDS_SUCC
 867  867       ES_MESSAGE_CORRECT       = LS_SUCC_MESSAGES
 868  868       ES_MASTER_DATA_DEFECTIVE = LS_CMDS_ERROR
 869  869       ES_MESSAGE_DEFECTIVE     = LS_ERR_MESSAGES.
 870  870 
 871  871   LOOP AT LS_ERR_MESSAGES-MESSAGES INTO LS_RETURN WHERE TYPE = 'A'
 872  872                     OR    TYPE = 'E'.
 873  873     FC_ERR = 'X'.
 874  874     EXIT.
 875  875   ENDLOOP.
 876  876 
 877  877   IF FC_ERR = 'X'.
 878  878     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
 879  879     APPEND LINES OF LS_ERR_MESSAGES-MESSAGES TO FT_RETURN .
 880  880     RETURN.
 881  881   ELSE.
 882  882     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
 883  883       EXPORTING
 884  884         WAIT = 'X'.
 885  885   ENDIF.
 886  886 ENDFORM.
 887  887 *&---------------------------------------------------------------------*
 888  888 *& Form FRM_SALES_CREATE
 889  889 *&---------------------------------------------------------------------*
 890  890 *& text
 891  891 *&---------------------------------------------------------------------*
 892  892 *      -->P_EFT_RETURN  text
 893  893 *      -->P_GS_BP_DATA  text
 894  894 *&---------------------------------------------------------------------*
 895  895 FORM FRM_SALES_CREATE  TABLES   FT_RETURN STRUCTURE BAPIRET2
 896  896                        USING    VALUE(FS_BP_DATA) TYPE ZSDS025
 897  897                        CHANGING  FC_ERR TYPE CHAR1 .
 898  898 
 899  899   DATA: LS_SALES          TYPE CMDS_EI_SALES,     "外部接口:销售数据
 900  900         LT_SALES          TYPE CMDS_EI_SALES_T,   "外部接口:销售数据
 901  901         LS_CMDS_FUNCTIONS TYPE CMDS_EI_FUNCTIONS, "外部接口:合作伙伴角色
 902  902         LT_CMDS_FUNCTIONS TYPE CMDS_EI_FUNCTIONS_T, "外部接口:合作伙伴角色
 903  903         LS_PURCHAS_DATA   TYPE CMDS_EI_CMD_FUNCTIONS, "外部接口:合作伙伴角色
 904  904         LS_CENTRAL_DATA   TYPE CMDS_EI_CENTRAL_DATA.  "外部界面:中心数据
 905  905 
 906  906   DATA: LS_CMDS_EXTERN   TYPE CMDS_EI_MAIN,  "外部接口:总计客户数据
 907  907         LS_SUCC_MESSAGES TYPE CVIS_MESSAGE,
 908  908         LS_CMDS_ERROR    TYPE CMDS_EI_MAIN,
 909  909         LS_ERR_MESSAGES  TYPE CVIS_MESSAGE,
 910  910         LS_RETURN        TYPE BAPIRET2,
 911  911         LS_CMDS_SUCC     TYPE CMDS_EI_MAIN.
 912  912 
 913  913   DATA: LS_CUSTOMERS TYPE CMDS_EI_EXTERN,    "客户的复合外部接口
 914  914         LT_CUSTOMERS TYPE CMDS_EI_EXTERN_T.  "客户的复合外部接口 (Tab.)
 915  915 
 916  916   DATA: LT_FKNVI LIKE FKNVI      OCCURS 0 WITH HEADER LINE, "客户主税收标识
 917  917         LS_KNVI  LIKE KNVI.
 918  918 
 919  919   CLEAR: LS_PURCHAS_DATA.
 920  920   CLEAR: LS_CUSTOMERS , LT_CUSTOMERS ,LT_CUSTOMERS[] .
 921  921   CLEAR: LS_CMDS_EXTERN  ,
 922  922          LS_SUCC_MESSAGES ,
 923  923          LS_CMDS_ERROR   ,
 924  924          LS_ERR_MESSAGES ,
 925  925          LS_CMDS_SUCC .
 926  926 
 927  927   DATA: LF_PARTNER TYPE KNA1-KUNNR .
 928  928   DATA: LF_LENTH TYPE INT4 .
 929  929   CLEAR LF_LENTH .
 930  930   LF_LENTH = STRLEN( FS_BP_DATA-PARTNER ) .
 931  931   IF LF_LENTH < 17 .
 932  932     LF_PARTNER = FS_BP_DATA-PARTNER .
 933  933   ELSE .
 934  934     LF_PARTNER = FS_BP_DATA-PARTNER+7(10) .
 935  935   ENDIF .
 936  936 
 937  937   LS_CUSTOMERS-HEADER-OBJECT_TASK = 'U'.
 938  938   LS_CUSTOMERS-HEADER-OBJECT_INSTANCE-KUNNR = LF_PARTNER .
 939  939 
 940  940   LS_SALES-TASK = 'I'.
 941  941   LS_SALES-DATA_KEY-VKORG = FS_BP_DATA-VKORG.   "销售组织
 942  942   LS_SALES-DATA_KEY-VTWEG = FS_BP_DATA-VTWEG.   "分销渠道
 943  943   LS_SALES-DATA_KEY-SPART = FS_BP_DATA-SPART.   "产品组
 944  944   LS_SALES-DATA-BZIRK = FS_BP_DATA-BZIRK.       "销售区域
 945  945   LS_SALES-DATA-KDGRP = FS_BP_DATA-KDGRP.       "客户组     KDGRP
 946  946   LS_SALES-DATA-WAERS = 'CNY'.                  "货币       WAERS
 947  947   LS_SALES-DATA-KONDA = '01'.                   "价格组     KONDA
 948  948   LS_SALES-DATA-VKBUR = FS_BP_DATA-VKBUR.       "销售办事处 VKBUR
 949  949   LS_SALES-DATA-KALKS = FS_BP_DATA-KALKS.       "客户分类
 950  950   LS_SALES-DATA-VERSG = '1'.                    "定价过程   VWERK
 951  951   LS_SALES-DATA-VWERK = FS_BP_DATA-VWERK.       "交货工厂   VWERK
 952  952   LS_SALES-DATA-KTGRD = FS_BP_DATA-KTGRD.       "此客户的账户分配组  KTGRD
 953  953   LS_SALES-DATA-AUTLF = 'X'.                    "全部交货   AUTLF
 954  954   LS_SALES-DATA-ANTLF = '1'.                    "最大部分交货ANTLF
 955  955   LS_SALES-DATA-KZTLF = 'B'.                    "部分交货   KZTLF
 956  956   LS_SALES-DATA-ZTERM = FS_BP_DATA-ZTERM.       "收付条件代码
 957  957 
 958  958 
 959  959   LS_SALES-DATAX-BZIRK = 'X'.
 960  960   LS_SALES-DATAX-KDGRP = 'X'.
 961  961   LS_SALES-DATAX-WAERS = 'X'.
 962  962   LS_SALES-DATAX-KONDA = 'X'.
 963  963   LS_SALES-DATAX-VKBUR = 'X'.
 964  964   LS_SALES-DATAX-KALKS = 'X'.
 965  965   LS_SALES-DATAX-VERSG = 'X'.
 966  966   LS_SALES-DATAX-VWERK = 'X'.
 967  967   LS_SALES-DATAX-KTGRD = 'X'.
 968  968   LS_SALES-DATAX-AUTLF = 'X'.
 969  969   LS_SALES-DATAX-ANTLF = 'X'.
 970  970   LS_SALES-DATAX-KZTLF = 'X'.
 971  971   LS_SALES-DATAX-ZTERM = 'X'.
 972  972 
 973  973   LS_CMDS_FUNCTIONS-TASK = 'I'.
 974  974   LS_CMDS_FUNCTIONS-DATA_KEY-PARVW = 'AG'.
 975  975   LS_CMDS_FUNCTIONS-DATA-PARTNER = FS_BP_DATA-KUNN2_PY.
 976  976   APPEND LS_CMDS_FUNCTIONS TO LT_CMDS_FUNCTIONS.
 977  977   CLEAR LS_CMDS_FUNCTIONS .
 978  978 
 979  979   LS_CMDS_FUNCTIONS-TASK = 'I'.
 980  980   LS_CMDS_FUNCTIONS-DATA_KEY-PARVW = 'RE'.
 981  981   LS_CMDS_FUNCTIONS-DATA-PARTNER = FS_BP_DATA-KUNN2_BP.
 982  982   APPEND LS_CMDS_FUNCTIONS TO LT_CMDS_FUNCTIONS.
 983  983   CLEAR LS_CMDS_FUNCTIONS .
 984  984 
 985  985   LS_CMDS_FUNCTIONS-TASK = 'I'.
 986  986   LS_CMDS_FUNCTIONS-DATA_KEY-PARVW = 'RG'.
 987  987   LS_CMDS_FUNCTIONS-DATA-PARTNER = FS_BP_DATA-KUNN2_PY.
 988  988   APPEND LS_CMDS_FUNCTIONS TO LT_CMDS_FUNCTIONS.
 989  989   CLEAR LS_CMDS_FUNCTIONS .
 990  990 
 991  991   LS_CMDS_FUNCTIONS-TASK = 'I'.
 992  992   LS_CMDS_FUNCTIONS-DATA_KEY-PARVW = 'WE'.
 993  993   LS_CMDS_FUNCTIONS-DATA-PARTNER = FS_BP_DATA-KUNN2_SH.
 994  994   APPEND LS_CMDS_FUNCTIONS TO LT_CMDS_FUNCTIONS.
 995  995   CLEAR LS_CMDS_FUNCTIONS .
 996  996 
 997  997   LS_PURCHAS_DATA-FUNCTIONS[] = LT_CMDS_FUNCTIONS[].
 998  998   MOVE-CORRESPONDING LS_PURCHAS_DATA TO LS_SALES-FUNCTIONS.
 999  999   APPEND LS_SALES TO LT_SALES.
1000 1000 
1001 1001   CLEAR LS_CUSTOMERS-SALES_DATA-SALES[].
1002 1002   LS_CUSTOMERS-SALES_DATA-SALES[] = LT_SALES[].
1003 1003 
1004 1004   CLEAR LT_CUSTOMERS[].
1005 1005   LS_CUSTOMERS-CENTRAL_DATA = LS_CENTRAL_DATA.
1006 1006   APPEND LS_CUSTOMERS TO LT_CUSTOMERS.
1007 1007 
1008 1008   CLEAR LS_CMDS_EXTERN-CUSTOMERS[].
1009 1009   LS_CMDS_EXTERN-CUSTOMERS[] = LT_CUSTOMERS[].
1010 1010 
1011 1011   LS_KNVI-KUNNR = LF_PARTNER.
1012 1012   LS_KNVI-ALAND = 'CN'.
1013 1013   LS_KNVI-TATYP = 'MWST'.
1014 1014   LS_KNVI-TAXKD =  '1'.
1015 1015   INSERT KNVI FROM LS_KNVI.
1016 1016 
1017 1017   CALL METHOD CMD_EI_API=>MAINTAIN_BAPI
1018 1018     EXPORTING
1019 1019       IV_COLLECT_MESSAGES      = 'X'
1020 1020       IS_MASTER_DATA           = LS_CMDS_EXTERN
1021 1021     IMPORTING
1022 1022       ES_MASTER_DATA_CORRECT   = LS_CMDS_SUCC
1023 1023       ES_MESSAGE_CORRECT       = LS_SUCC_MESSAGES
1024 1024       ES_MASTER_DATA_DEFECTIVE = LS_CMDS_ERROR
1025 1025       ES_MESSAGE_DEFECTIVE     = LS_ERR_MESSAGES.
1026 1026 
1027 1027   LOOP AT LS_ERR_MESSAGES-MESSAGES INTO LS_RETURN WHERE TYPE = 'A'
1028 1028                     OR    TYPE = 'E'.
1029 1029     FC_ERR = 'X'.
1030 1030     EXIT.
1031 1031   ENDLOOP.
1032 1032 
1033 1033   IF FC_ERR = 'X'.
1034 1034     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
1035 1035     APPEND LINES OF LS_ERR_MESSAGES-MESSAGES TO FT_RETURN .
1036 1036     RETURN.
1037 1037   ELSE.
1038 1038     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
1039 1039       EXPORTING
1040 1040         WAIT = 'X'.
1041 1041   ENDIF.
1042 1042 ENDFORM.
1043 1043 *&---------------------------------------------------------------------*
1044 1044 *& Form FRM_SALES_CHANGE
1045 1045 *&---------------------------------------------------------------------*
1046 1046 *& text
1047 1047 *&---------------------------------------------------------------------*
1048 1048 *      -->P_EFT_RETURN  text
1049 1049 *      -->P_GS_BP_DATA  text
1050 1050 *&---------------------------------------------------------------------*
1051 1051 FORM FRM_SALES_CHANGE  TABLES   FT_RETURN STRUCTURE BAPIRET2
1052 1052                        USING    VALUE(FS_BP_DATA) TYPE ZSDS025
1053 1053                        CHANGING  FC_ERR TYPE CHAR1 .
1054 1054 
1055 1055   DATA: LS_SALES          TYPE CMDS_EI_SALES,     "外部接口:销售数据
1056 1056         LT_SALES          TYPE CMDS_EI_SALES_T,   "外部接口:销售数据
1057 1057         LS_CMDS_FUNCTIONS TYPE CMDS_EI_FUNCTIONS, "外部接口:合作伙伴角色
1058 1058         LT_CMDS_FUNCTIONS TYPE CMDS_EI_FUNCTIONS_T, "外部接口:合作伙伴角色
1059 1059         LS_PURCHAS_DATA   TYPE CMDS_EI_CMD_FUNCTIONS, "外部接口:合作伙伴角色
1060 1060         LS_CENTRAL_DATA   TYPE CMDS_EI_CENTRAL_DATA.  "外部界面:中心数据
1061 1061 
1062 1062   DATA: LS_CMDS_EXTERN   TYPE CMDS_EI_MAIN,  "外部接口:总计客户数据
1063 1063         LS_SUCC_MESSAGES TYPE CVIS_MESSAGE,
1064 1064         LS_CMDS_ERROR    TYPE CMDS_EI_MAIN,
1065 1065         LS_ERR_MESSAGES  TYPE CVIS_MESSAGE,
1066 1066         LS_RETURN        TYPE BAPIRET2,
1067 1067         LS_CMDS_SUCC     TYPE CMDS_EI_MAIN.
1068 1068 
1069 1069   DATA: LS_CUSTOMERS TYPE CMDS_EI_EXTERN,    "客户的复合外部接口
1070 1070         LT_CUSTOMERS TYPE CMDS_EI_EXTERN_T.  "客户的复合外部接口 (Tab.)
1071 1071 
1072 1072   DATA: LT_FKNVI LIKE FKNVI      OCCURS 0 WITH HEADER LINE, "客户主税收标识
1073 1073         LS_KNVI  LIKE KNVI.
1074 1074 
1075 1075   CLEAR: LS_PURCHAS_DATA.
1076 1076   CLEAR: LS_CUSTOMERS , LT_CUSTOMERS ,LT_CUSTOMERS[] .
1077 1077   CLEAR: LS_CMDS_EXTERN  ,
1078 1078          LS_SUCC_MESSAGES ,
1079 1079          LS_CMDS_ERROR   ,
1080 1080          LS_ERR_MESSAGES ,
1081 1081          LS_CMDS_SUCC .
1082 1082 
1083 1083   DATA: LF_PARTNER TYPE KNA1-KUNNR .
1084 1084   DATA: LF_LENTH TYPE INT4 .
1085 1085   CLEAR LF_LENTH .
1086 1086   LF_LENTH = STRLEN( FS_BP_DATA-PARTNER ) .
1087 1087   IF LF_LENTH < 17 .
1088 1088     LF_PARTNER = FS_BP_DATA-PARTNER .
1089 1089   ELSE .
1090 1090     LF_PARTNER = FS_BP_DATA-PARTNER+7(10) .
1091 1091   ENDIF .
1092 1092 
1093 1093 
1094 1094   LS_CUSTOMERS-HEADER-OBJECT_TASK = 'U'.
1095 1095   LS_CUSTOMERS-HEADER-OBJECT_INSTANCE-KUNNR = LF_PARTNER .
1096 1096 
1097 1097   LS_SALES-TASK = 'U'.
1098 1098   LS_SALES-DATA_KEY-VKORG = FS_BP_DATA-VKORG.   "销售组织
1099 1099   LS_SALES-DATA_KEY-VTWEG = FS_BP_DATA-VTWEG.   "分销渠道
1100 1100   LS_SALES-DATA_KEY-SPART = FS_BP_DATA-SPART.   "产品组
1101 1101   LS_SALES-DATA-BZIRK = FS_BP_DATA-BZIRK.       "销售区域
1102 1102   LS_SALES-DATA-KDGRP = FS_BP_DATA-KDGRP.       "客户组BZIRK
1103 1103   LS_SALES-DATA-WAERS = 'CNY'.                  "货币    WAERS
1104 1104   LS_SALES-DATA-KONDA = '01'.                   "价格组  KONDA
1105 1105   LS_SALES-DATA-VKBUR = FS_BP_DATA-VKBUR.       "销售办事处   VKBUR
1106 1106   LS_SALES-DATA-KALKS = FS_BP_DATA-KALKS.       "客户分类
1107 1107   LS_SALES-DATA-KALKS = '1'.                    "定价过程
1108 1108   LS_SALES-DATA-VERSG = '1'.                    "定价过程VWERK
1109 1109   LS_SALES-DATA-VWERK = FS_BP_DATA-VWERK.       "VWERK  LPRIO
1110 1110   LS_SALES-DATA-KTGRD = FS_BP_DATA-KTGRD.       "此客户的账户分配组
1111 1111   LS_SALES-DATA-AUTLF = 'X'.                    "LPRIO
1112 1112   LS_SALES-DATA-ANTLF = '1'.                    "最大部分交货 ANTLF
1113 1113   LS_SALES-DATA-KZTLF = 'B'.                    "部分交货KZTLF
1114 1114   LS_SALES-DATA-ZTERM = FS_BP_DATA-ZTERM.       "ANTLF KZTLF ZTERM
1115 1115 
1116 1116 
1117 1117   LS_SALES-DATAX-BZIRK = 'X'.
1118 1118   LS_SALES-DATAX-KDGRP = 'X'.
1119 1119   LS_SALES-DATAX-WAERS = 'X'.
1120 1120   LS_SALES-DATAX-KONDA = 'X'.
1121 1121   LS_SALES-DATAX-VKBUR = 'X'.
1122 1122   LS_SALES-DATAX-KALKS = 'X'.
1123 1123   LS_SALES-DATAX-VERSG = 'X'.
1124 1124   LS_SALES-DATAX-VWERK = 'X'.
1125 1125   LS_SALES-DATAX-KTGRD = 'X'.
1126 1126   LS_SALES-DATAX-AUTLF = 'X'.
1127 1127   LS_SALES-DATAX-ANTLF = 'X'.
1128 1128   LS_SALES-DATAX-KZTLF = 'X'.
1129 1129   LS_SALES-DATAX-ZTERM = 'X'.
1130 1130 
1131 1131   LS_CMDS_FUNCTIONS-TASK = 'U'.
1132 1132   LS_CMDS_FUNCTIONS-DATA_KEY-PARVW = 'AG'.
1133 1133   LS_CMDS_FUNCTIONS-DATA-PARTNER = FS_BP_DATA-KUNN2_PY.
1134 1134   LS_CMDS_FUNCTIONS-DATAX-PARTNER = 'X'.
1135 1135   APPEND LS_CMDS_FUNCTIONS TO LT_CMDS_FUNCTIONS.
1136 1136   CLEAR LS_CMDS_FUNCTIONS .
1137 1137 
1138 1138   LS_CMDS_FUNCTIONS-TASK = 'U'.
1139 1139   LS_CMDS_FUNCTIONS-DATA_KEY-PARVW = 'RE'.
1140 1140   LS_CMDS_FUNCTIONS-DATA-PARTNER = FS_BP_DATA-KUNN2_BP.
1141 1141   LS_CMDS_FUNCTIONS-DATAX-PARTNER = 'X'.
1142 1142   APPEND LS_CMDS_FUNCTIONS TO LT_CMDS_FUNCTIONS.
1143 1143   CLEAR LS_CMDS_FUNCTIONS .
1144 1144 
1145 1145   LS_CMDS_FUNCTIONS-TASK = 'U'.
1146 1146   LS_CMDS_FUNCTIONS-DATA_KEY-PARVW = 'RG'.
1147 1147   LS_CMDS_FUNCTIONS-DATA-PARTNER = FS_BP_DATA-KUNN2_PY.
1148 1148   LS_CMDS_FUNCTIONS-DATAX-PARTNER = 'X'.
1149 1149   APPEND LS_CMDS_FUNCTIONS TO LT_CMDS_FUNCTIONS.
1150 1150   CLEAR LS_CMDS_FUNCTIONS .
1151 1151 
1152 1152 *  LS_CMDS_FUNCTIONS-TASK = 'U'.
1153 1153 *  LS_CMDS_FUNCTIONS-DATA_KEY-PARVW = 'WE'.
1154 1154 *  LS_CMDS_FUNCTIONS-DATA-PARTNER = FS_BP_DATA-KUNN2_SH.
1155 1155 *  APPEND LS_CMDS_FUNCTIONS TO LT_CMDS_FUNCTIONS.
1156 1156 *  CLEAR LS_CMDS_FUNCTIONS .
1157 1157 
1158 1158   LS_PURCHAS_DATA-FUNCTIONS[] = LT_CMDS_FUNCTIONS[].
1159 1159   MOVE-CORRESPONDING LS_PURCHAS_DATA TO LS_SALES-FUNCTIONS.
1160 1160   APPEND LS_SALES TO LT_SALES.
1161 1161 
1162 1162   CLEAR LS_CUSTOMERS-SALES_DATA-SALES[].
1163 1163   LS_CUSTOMERS-SALES_DATA-SALES[] = LT_SALES[].
1164 1164 
1165 1165   CLEAR LT_CUSTOMERS[].
1166 1166   LS_CUSTOMERS-CENTRAL_DATA = LS_CENTRAL_DATA.
1167 1167   APPEND LS_CUSTOMERS TO LT_CUSTOMERS.
1168 1168 
1169 1169   CLEAR LS_CMDS_EXTERN-CUSTOMERS[].
1170 1170   LS_CMDS_EXTERN-CUSTOMERS[] = LT_CUSTOMERS[].
1171 1171 
1172 1172   LS_KNVI-KUNNR = LF_PARTNER.
1173 1173   LS_KNVI-ALAND = 'CN'.
1174 1174   LS_KNVI-TATYP = 'MWST'.
1175 1175   LS_KNVI-TAXKD =  '1'.
1176 1176   INSERT KNVI FROM LS_KNVI.
1177 1177 
1178 1178   CALL METHOD CMD_EI_API=>MAINTAIN_BAPI
1179 1179     EXPORTING
1180 1180       IV_COLLECT_MESSAGES      = 'X'
1181 1181       IS_MASTER_DATA           = LS_CMDS_EXTERN
1182 1182     IMPORTING
1183 1183       ES_MASTER_DATA_CORRECT   = LS_CMDS_SUCC
1184 1184       ES_MESSAGE_CORRECT       = LS_SUCC_MESSAGES
1185 1185       ES_MASTER_DATA_DEFECTIVE = LS_CMDS_ERROR
1186 1186       ES_MESSAGE_DEFECTIVE     = LS_ERR_MESSAGES.
1187 1187   LOOP AT LS_ERR_MESSAGES-MESSAGES INTO LS_RETURN WHERE TYPE = 'A'
1188 1188                     OR    TYPE = 'E'.
1189 1189     FC_ERR = 'X'.
1190 1190     EXIT.
1191 1191   ENDLOOP.
1192 1192 
1193 1193   IF FC_ERR = 'X'.
1194 1194     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
1195 1195     APPEND LINES OF LS_ERR_MESSAGES-MESSAGES TO FT_RETURN .
1196 1196     RETURN.
1197 1197   ELSE.
1198 1198     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
1199 1199       EXPORTING
1200 1200         WAIT = 'X'.
1201 1201   ENDIF.
1202 1202 ENDFORM.
1203 1203 *&---------------------------------------------------------------------*
1204 1204 *& Form FRM_CREDIT_CREATE
1205 1205 *&---------------------------------------------------------------------*
1206 1206 *& text
1207 1207 *&---------------------------------------------------------------------*
1208 1208 *      -->P_EFT_RETURN  text
1209 1209 *      -->P_GS_BP_DATA_PARTNER  text
1210 1210 *      -->P_GS_BP_DATA_LIMIT_RULE  text
1211 1211 *      <--P_GF_ERR  text
1212 1212 *&---------------------------------------------------------------------*
1213 1213 FORM FRM_CREDIT_CREATE  TABLES   FT_RETURN STRUCTURE BAPIRET2
1214 1214                         USING VALUE(FU_PARTNER)  TYPE ZSDS025-PARTNER
1215 1215                               VALUE(FU_LIMIT_RULE)  TYPE ZSDS025-LIMIT_RULE
1216 1216                         CHANGING  FC_ERR TYPE CHAR1 .
1217 1217   DATA: LT_RETURN TYPE TABLE OF BAPIRET2,
1218 1218         LS_RETURN TYPE BAPIRET2.
1219 1219   CLEAR: LT_RETURN ,LT_RETURN[].
1220 1220 
1221 1221   DATA: LF_PARTNER      LIKE BUT000-PARTNER.
1222 1222   DATA: IO_FACADE        TYPE REF TO CL_UKM_FACADE,
1223 1223         IO_PARTNER       TYPE REF TO CL_UKM_BUSINESS_PARTNER,
1224 1224         IO_BUPA_FACTORY  TYPE REF TO CL_UKM_BUPA_FACTORY,
1225 1225         IO_ACCOUNT       TYPE REF TO CL_UKM_ACCOUNT,
1226 1226         LW_BP_CREDIT_SGM TYPE UKM_S_BP_CMS_SGM.
1227 1227 
1228 1228   DATA: LWA_UKM_S_BP_CMS TYPE UKM_S_BP_CMS.
1229 1229   DATA: LV_CREDIT_SGMNT TYPE UKM_CREDIT_SGMNT.
1230 1230   CLEAR LF_PARTNER .
1231 1231 
1232 1232   DATA: LF_LENTH TYPE INT4 .
1233 1233   CLEAR LF_LENTH .
1234 1234   LF_LENTH = STRLEN( FU_PARTNER ) .
1235 1235   IF LF_LENTH < 17 .
1236 1236     LF_PARTNER = FU_PARTNER .
1237 1237   ELSE .
1238 1238     LF_PARTNER = FU_PARTNER+7(10) .
1239 1239   ENDIF .
1240 1240 
1241 1241   IO_FACADE = CL_UKM_FACADE=>CREATE( I_ACTIVITY = CL_UKM_CNST_EVENTING=>BP_MAINTENANCE ).
1242 1242   IO_BUPA_FACTORY = IO_FACADE->GET_BUPA_FACTORY( ).
1243 1243 
1244 1244   CLEAR LF_LENTH .
1245 1245   LF_LENTH = STRLEN( FU_PARTNER ) .
1246 1246   IF LF_LENTH < 17 .
1247 1247     LF_PARTNER = FU_PARTNER .
1248 1248   ELSE .
1249 1249     LF_PARTNER = FU_PARTNER+7(10) .
1250 1250   ENDIF .
1251 1251 
1252 1252   IO_PARTNER = IO_BUPA_FACTORY->GET_BUSINESS_PARTNER( LF_PARTNER ).
1253 1253   IO_PARTNER->GET_BP_CMS( IMPORTING ES_BP_CMS =  LWA_UKM_S_BP_CMS ).
1254 1254   LWA_UKM_S_BP_CMS-LIMIT_RULE = FU_LIMIT_RULE.
1255 1255   IO_PARTNER->SET_BP_CMS( LWA_UKM_S_BP_CMS ).
1256 1256   LT_RETURN = IO_BUPA_FACTORY->SAVE_ALL( ).
1257 1257 
1258 1258   LOOP AT LT_RETURN INTO LS_RETURN WHERE TYPE = 'A'
1259 1259                     OR    TYPE = 'E'.
1260 1260     FC_ERR = 'X'.
1261 1261     EXIT.
1262 1262   ENDLOOP.
1263 1263 
1264 1264   IF FC_ERR = 'X'.
1265 1265     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
1266 1266     APPEND LINES OF LT_RETURN TO FT_RETURN .
1267 1267     RETURN.
1268 1268   ELSE.
1269 1269     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
1270 1270       EXPORTING
1271 1271         WAIT = 'X'.
1272 1272   ENDIF.
1273 1273 
1274 1274 ENDFORM.
1275 1275 *&---------------------------------------------------------------------*
1276 1276 *& Form FRM_CREDIT_CHANGE
1277 1277 *&---------------------------------------------------------------------*
1278 1278 *& text
1279 1279 *&---------------------------------------------------------------------*
1280 1280 *      -->P_EFT_RETURN  text
1281 1281 *      -->P_GS_BP_DATA_PARTNER  text
1282 1282 *      -->P_GS_BP_DATA_LIMIT_RULE  text
1283 1283 *      <--P_GF_ERR  text
1284 1284 *&---------------------------------------------------------------------*
1285 1285 FORM FRM_CREDIT_CHANGE  TABLES   FT_RETURN STRUCTURE BAPIRET2
1286 1286                         USING VALUE(FU_PARTNER)  TYPE ZSDS025-PARTNER
1287 1287                               VALUE(FU_LIMIT_RULE)  TYPE ZSDS025-LIMIT_RULE
1288 1288                         CHANGING  FC_ERR TYPE CHAR1 .
1289 1289   DATA: LT_RETURN TYPE TABLE OF BAPIRET2,
1290 1290         LS_RETURN TYPE BAPIRET2.
1291 1291   CLEAR: LT_RETURN ,LT_RETURN[].
1292 1292 
1293 1293   DATA: LF_PARTNER       LIKE BUT000-PARTNER.
1294 1294   DATA: IO_FACADE        TYPE REF TO CL_UKM_FACADE,
1295 1295         IO_PARTNER       TYPE REF TO CL_UKM_BUSINESS_PARTNER,
1296 1296         IO_BUPA_FACTORY  TYPE REF TO CL_UKM_BUPA_FACTORY,
1297 1297         IO_ACCOUNT       TYPE REF TO CL_UKM_ACCOUNT,
1298 1298         LW_BP_CREDIT_SGM TYPE UKM_S_BP_CMS_SGM.
1299 1299   DATA: LWA_UKM_S_BP_CMS TYPE UKM_S_BP_CMS.
1300 1300   DATA: LV_CREDIT_SGMNT TYPE UKM_CREDIT_SGMNT.
1301 1301   CLEAR LF_PARTNER .
1302 1302 
1303 1303   DATA: LF_LENTH TYPE INT4 .
1304 1304   CLEAR LF_LENTH .
1305 1305   LF_LENTH = STRLEN( FU_PARTNER ) .
1306 1306   IF LF_LENTH < 17 .
1307 1307     LF_PARTNER = FU_PARTNER .
1308 1308   ELSE .
1309 1309     LF_PARTNER = FU_PARTNER+7(10) .
1310 1310   ENDIF .
1311 1311 
1312 1312   IO_FACADE = CL_UKM_FACADE=>CREATE( I_ACTIVITY = CL_UKM_CNST_EVENTING=>BP_MAINTENANCE ).
1313 1313   IO_BUPA_FACTORY = IO_FACADE->GET_BUPA_FACTORY( ).
1314 1314 
1315 1315   CLEAR LF_LENTH .
1316 1316   LF_LENTH = STRLEN( FU_PARTNER ) .
1317 1317   IF LF_LENTH < 17 .
1318 1318     LF_PARTNER = FU_PARTNER .
1319 1319   ELSE .
1320 1320     LF_PARTNER = FU_PARTNER+7(10) .
1321 1321   ENDIF .
1322 1322 
1323 1323   IO_PARTNER = IO_BUPA_FACTORY->GET_BUSINESS_PARTNER( LF_PARTNER ).
1324 1324   IO_PARTNER->GET_BP_CMS( IMPORTING ES_BP_CMS =  LWA_UKM_S_BP_CMS ).
1325 1325   LWA_UKM_S_BP_CMS-LIMIT_RULE = FU_LIMIT_RULE.
1326 1326   IO_PARTNER->SET_BP_CMS( LWA_UKM_S_BP_CMS ).
1327 1327   LT_RETURN = IO_BUPA_FACTORY->SAVE_ALL( ).
1328 1328 
1329 1329   LOOP AT LT_RETURN INTO LS_RETURN WHERE TYPE = 'A'
1330 1330                     OR    TYPE = 'E'.
1331 1331     FC_ERR = 'X'.
1332 1332     EXIT.
1333 1333   ENDLOOP.
1334 1334 
1335 1335   IF FC_ERR = 'X'.
1336 1336     CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
1337 1337     APPEND LINES OF LT_RETURN TO FT_RETURN .
1338 1338     RETURN.
1339 1339   ELSE.
1340 1340     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
1341 1341       EXPORTING
1342 1342         WAIT = 'X'.
1343 1343   ENDIF.
1344 1344 
1345 1345 ENDFORM.
View Code

 

posted on 2021-07-20 14:20  雨水果冻  阅读(147)  评论(0编辑  收藏  举报