BP销售与分销主数据中保存了许多对客商分组的字段,后台的存储表如下:销售部门TVKBT 销售组TVGRT 销售地区T005U
1、销售部门
SELECT * FROM tvkbt
2、销售组 TVGRT
SELECT * FROM TVGRT
3、销售地区
SELECT kunnr,name1, regio,ort01 FROM kna1 WHERE kunnr like '%021' SELECT * FROM t005u WHERE land1 = 'CN' AND spras = '1' and bland = '100' and mandt='800' ** bland = '100' 是主要条件,是地区的内部编码
查询KNA1的REGIO字段执行结果
T005U的执行结果
附:BP主数据维护视图
表太多了,借同事的代码学习下,他山之石,可以攻玉;
* 查询组织各结构 * 查询组织 SELECT vkorg, vtext INTO TABLE @DATAvkorg) FROM tvkot FOR ALL ENTRIES IN @gt_out WHERE vkorg = @gt_out-vkorg AND spras = '1' . LOOP AT vkorg ASSIGNING FIELD-SYMBOL<vkorg>). CLEAR gt_out. gt_out-zzz = <vkorg>-vtext. MODIFY gt_out FROM gt_out TRANSPORTING zzz WHERE vkorg = <vkorg>-vkorg. ENDLOOP. * 查询渠道 SELECT vtweg, vtext INTO TABLE @DATAvtweg) FROM tvtwt FOR ALL ENTRIES IN @gt_out WHERE vtweg = @gt_out-vtweg AND spras = '1' . LOOP AT vtweg ASSIGNING FIELD-SYMBOL<vtweg>). CLEAR gt_out. gt_out-zqd = <vtweg>-vtext. MODIFY gt_out FROM gt_out TRANSPORTING zqd WHERE vtweg = <vtweg>-vtweg. ENDLOOP. * 查询办公室 SELECT vkbur, bezei INTO TABLE @DATAvkbur) FROM tvkbt FOR ALL ENTRIES IN @gt_out WHERE vkbur = @gt_out-vkbur AND spras = '1' . LOOP AT vkbur ASSIGNING FIELD-SYMBOL<vkbur>). CLEAR gt_out. gt_out-zbgs = <vkbur>-bezei. MODIFY gt_out FROM gt_out TRANSPORTING zbgs WHERE vkbur = <vkbur>-vkbur. ENDLOOP. * 查询销售组 SELECT vkgrp, bezei INTO TABLE @DATAvkgrp) FROM tvgrt FOR ALL ENTRIES IN @gt_out WHERE vkgrp = @gt_out-vkgrp AND spras = '1' . LOOP AT vkgrp ASSIGNING FIELD-SYMBOL<vkgrp>). CLEAR gt_out. gt_out-zxsz = <vkgrp>-bezei. MODIFY gt_out FROM gt_out TRANSPORTING zxsz WHERE vkgrp = <vkgrp>-vkgrp. ENDLOOP. * 查询产品组 SELECT spart, vtext INTO TABLE @DATAspart) FROM tspat FOR ALL ENTRIES IN @gt_out WHERE spart = @gt_out-spart AND spras = '1' . LOOP AT spart ASSIGNING FIELD-SYMBOL<spart>). CLEAR gt_out. gt_out-zcpz = <spart>-vtext. MODIFY gt_out FROM gt_out TRANSPORTING zcpz WHERE spart = <spart>-spart. ENDLOOP. * 查询销售地区 SELECT bzirk, bztxt INTO TABLE @DATAbzirk) FROM t171t FOR ALL ENTRIES IN @gt_out WHERE bzirk = @gt_out-bzirk AND spras = '1' . LOOP AT bzirk ASSIGNING FIELD-SYMBOL<bzirk>). CLEAR gt_out. gt_out-zxsdq = <bzirk>-bztxt. MODIFY gt_out FROM gt_out TRANSPORTING zxsdq WHERE bzirk = <bzirk>-bzirk. ENDLOOP. * 查询客户类型描述 SELECT kdgrp,ktext INTO TABLE @DATAkhlx) FROM t151t FOR ALL ENTRIES IN @table WHERE kdgrp = @table-kdgrp AND spras = '1'.
活到老,学到老。