abap不同数据库表(三个)的内关联问题?哪位能给个例子介绍一下 abap中三个表之间的关联怎么建立?写段代码呗?
abap\u5b9a\u4e49\u5185\u8868\u7684\u95ee\u98981. \u4f60\u5199\u7684\u4ee3\u7801\u662f\u600e\u6837\u7684\uff1f\u6709\u53ef\u80fd\u662f\u6ca1\u6ce8\u610fDATA\u548cTYPES\u7684\u533a\u522b\u3002types c1(30) type c.data itab1 type table of c1.data c2(30) type c.data itab2 like table of c2.2. char30\u662f\u4e00\u4e2aData element\uff0c\u76f8\u5f53\u4e8eData typeCHAR\uff0c Length 303. char\u662f\u6570\u636e\u5b57\u5178\u4e2d\u7684\u4e00\u79cd\u6570\u636e\u7c7b\u578b(\u540c\u7c7b\u7684\u6709ACCP\u3001DATS\u3001QUAN\u7b49)\uff0c c\u662fABAP\u4e2d\u7684\u6570\u636e\u7c7b\u578b(\u540c\u7c7b\u7684\u6709C\u3001N\u3001D\u3001T\u3001X\u3001I\u3001P\u3001F\u3001STRING\u3001XSTRING)\u3002\u6570\u636e\u5b57\u5178\u4e2d\u7684\u6570\u636e\u7c7b\u578b\u662fuser interface\u5c42\u5bf9\u6570\u636e\u7684\u5206\u7c7b\uff0c\u7528\u8fd9\u79cd\u5206\u7c7b\u5b9a\u4e49\u7684table field \u3001structure field\u6216data element\u7528\u5728ABAP\u7a0b\u5e8f\u65f6\uff0cABAP\u5904\u7406\u5668\u4f1a\u628a\u5b83\u8f6c\u6362\u6210C\uff0cN\uff0cD\u8fd9\u6837\u7684\u7c7b\u578b\u3002\u5728\u6570\u636e\u5e93\u4e2d\u521b\u5efa\u8868\u65f6\uff0c\u6570\u636e\u5b57\u5178\u7684\u6570\u636e\u7c7b\u578b\u5c31\u4f1a\u8f6c\u6362\u6210\u6570\u636e\u5e93\u7cfb\u7edf\u6240\u7528\u7684\u7c7b\u578b\u3002
\u5148\u628a3\u4e2a\u8868\u90fd\u63d2\u5165\u5185\u8868
\u5faa\u73af\u5176\u4e2d\u4e00\u4e2a\u8868\uff0c\u5728read\u53e6\u5916\u7684\u8868\uff0c\u8fd9\u6837\u53ef\u4ee5\u65b9\u4fbf\u4e00\u9700\u8981\u5904\u7406\u6570\u636e\u7684\u60c5\u51b5
select single c~pspid c~post1 into (it_prchg-pspid , it_prchg-post1)
from ebkn as a
inner join prps as b on a~ps_psp_pnr = b~pspnr "内联WBS元素的表
inner join proj as c on b~paphi = c~pspnr "内联项目的表
where banfn = it_prchg-banfn.
给你个更多表连接的例子:
select RBCO~BELNR RBCO~BNKAN_FW RBCO~BUZEI RBCO~GJAHR RBCO~GSBER RBCO~SHKZG RBCO~WRBTR RSEG~BELNR RSEG~BUZEI RSEG~EBELN RSEG~EBELP
RSEG~GJAHR RBKP~BELNR RBKP~GJAHR EKPO~BANFN EKPO~BNFPO EKPO~EBELN EKPO~EBELP EKPO~TXZ01 EKKO~EBELN EKKO~EKGRP EKKO~LIFNR
EKKN~AEDAT EKKN~AUFNR EKKN~EBELN EKKN~EBELP EKKN~KOSTL AFVC~APLZL AFVC~AUFPL AFVC~BANFN AFVC~BNFPO LFBK~BANKL LFBK~BANKN
LFBK~BANKS LFBK~BKONT LFBK~LIFNR AUFK~AUART AUFK~AUFNR AUFK~KOKRS AUFK~KTEXT AUFK~ZZEND_DT AUFK~ZZST_DT AUFK~ZZSYUNKOU
OPROL~APLZL OPROL~AUFPL OPROL~OBKNR OPROL~OBZAE AFIH~ARTPR AFIH~AUFNR AFIH~ILOAN AFIH~PRIOK BNKA~BANKA BNKA~BANKL BNKA~BANKS
BNKA~BRNCH ILOA~ILOAN ILOA~TPLNR LFA1~LIFNR LFA1~NAME1 QMIH~BAUTL QMIH~ILOAN
into (RBCO-BELNR , RBCO-BNKAN_FW , RBCO-BUZEI , RBCO-GJAHR , RBCO-GSBER , RBCO-SHKZG , RBCO-WRBTR , RSEG-BELNR , RSEG-BUZEI, RSEG-EBELN , RSEG-EBELP , RSEG-GJAHR , RBKP-BELNR , RBKP-GJAHR , EKPO-BANFN , EKPO-BNFPO , EKPO-EBELN , EKPO-EBELP, EKPO-TXZ01 , EKKO-EBELN , EKKO-EKGRP , EKKO-LIFNR , EKKN-AEDAT , EKKN-AUFNR , EKKN-EBELN , EKKN-EBELP , EKKN-KOSTL, AFVC-APLZL , AFVC-AUFPL , AFVC-BANFN , AFVC-BNFPO , LFBK-BANKL , LFBK-BANKN , LFBK-BANKS , LFBK-BKONT , LFBK-LIFNR, AUFK-AUART , AUFK-AUFNR , AUFK-KOKRS , AUFK-KTEXT , AUFK-ZZEND_DT , AUFK-ZZST_DT , AUFK-ZZSYUNKOU , OPROL-APLZL, OPROL-AUFPL , OPROL-OBKNR , OPROL-OBZAE , AFIH-ARTPR , AFIH-AUFNR , AFIH-ILOAN , AFIH-PRIOK , BNKA-BANKA , BNKA-BANKL, BNKA-BANKS , BNKA-BRNCH , ILOA-ILOAN , ILOA-TPLNR , LFA1-LIFNR , LFA1-NAME1 , QMIH-BAUTL , QMIH-ILOAN )
from ( RBCO
inner join RSEG
on RSEG~BELNR = RBCO~BELNR
and RSEG~BUZEI = RBCO~BUZEI
and RSEG~GJAHR = RBCO~GJAHR
inner join RBKP
on RBKP~BELNR = RSEG~BELNR
and RBKP~GJAHR = RSEG~GJAHR
inner join EKPO
on EKPO~EBELN = RSEG~EBELN
and EKPO~EBELP = RSEG~EBELP
inner join EKKO
on EKKO~EBELN = EKPO~EBELN
inner join EKKN
on EKKN~EBELN = EKPO~EBELN
and EKKN~EBELP = EKPO~EBELP
inner join AFVC
on AFVC~BANFN = EKPO~BANFN
and AFVC~BNFPO = EKPO~BNFPO
inner join LFBK
on LFBK~LIFNR = EKKO~LIFNR
inner join AUFK
on AUFK~AUFNR = EKKN~AUFNR
left outer join OPROL
on OPROL~APLZL = AFVC~APLZL
and OPROL~AUFPL = AFVC~AUFPL
inner join AFIH
on AFIH~AUFNR = AUFK~AUFNR
inner join BNKA
on BNKA~BANKL = LFBK~BANKL
and BNKA~BANKS = LFBK~BANKS
inner join ILOA
on ILOA~ILOAN = AFIH~ILOAN
inner join LFA1
on LFA1~LIFNR = LFBK~LIFNR
left outer join QMIH
on QMIH~ILOAN = ILOA~ILOAN )
where RBCO~GJAHR in GJAHR
and EKKO~EKGRP in KOBAIGRP
and AUFK~AUFNR in SASHIZU
and AUFK~ZZSYUNKOU in SYUNKOU
and AUFK~ZZST_DT in YOUTEIBI
and ILOA~TPLNR in KINOUBAS.
for all entries。。。
绛旓細select single c~pspid c~post1 into (it_prchg-pspid , it_prchg-post1)from ebkn as a inner join prps as b on a~ps_psp_pnr = b~pspnr "鍐呰仈WBS鍏冪礌鐨勮〃 inner join proj as c on b~paphi = c~pspnr "鍐呰仈椤圭洰鐨勮〃 where banfn = it_prchg-banfn....
绛旓細涓銆佸畾涔夊彉閲忎笌璧嬪</ 鍦ABAP缂栫▼涓紝鍙橀噺鐨勫0鏄庝笌璧嬪兼槸鍩虹鎿嶄綔銆備緥濡傦紝閫氳繃lifnr TYPE lfa1-lifnr锛屾垜浠彲浠ュ垱寤轰竴涓彉閲忥紝鍏剁被鍨嬪搴鏁版嵁搴撹〃lfa1鐨刲ifnr瀛楁銆傚湪SE38缂栫▼鐜涓紝浣犲彲浠ョ洿鎺ユ煡鐪嬪埌鐩稿叧鐨勬暟鎹簱琛ㄣ備簩銆佽嚜瀹氫箟绫诲瀷涓庡唴琛</ 浣跨敤types瀹氫箟鏁版嵁绫诲瀷锛屽Lty_lfa1_2锛屽寘鍚簡鏁版嵁搴撹〃l...
绛旓細1銆佹寜F1锛屾煡鐪鏁版嵁鍏冪礌锛屾牴鎹暟鎹厓绱犳煡鐩稿叧琛 2銆丼T05璺熻釜鏌ユ壘
绛旓細type ref to 灞炰簬ABAP涓闈㈠悜瀵硅薄鐨勭紪绋嬨傚畠鏄畾涔変竴涓被鐨勫璞°5>閫氳繃鏁版嵁搴撹〃瀹氫箟 data itab1 type table of sflight . 鈥 瀹氫箟涓涓笉甯﹀唴琛ㄧ殑宸ヤ綔鍖 data wa1 like line of sflgit . 鈥 瀹氫箟涓涓唴琛ㄥ伐浣滃尯 data itab1 type table of sflight with header line . 鈥滃畾涔変竴涓甫...
绛旓細OpenSQL鏄ABAP/4鐨勪竴涓猄QL瀛愰泦锛屼娇寰楀紑鍙戣呭彲浠ョ嫭绔嬩簬鐗瑰畾鏁版嵁搴绯荤粺杩涜鏁版嵁璇诲彇鍜岃闂傝繖瀵逛簬鏁版嵁鐨勯泦鎴愬拰绠$悊闈炲父鏈夌敤銆傚唴閮ㄨ〃鏄疉BAP/4鐨勭壒鑹诧紝瀹冩槸鍦ㄧ▼搴忚繍琛屾椂涓存椂鍒涘缓鐨勶紝渚夸簬鏁版嵁澶勭悊鍜屽鏉傜殑绋嬪簭鏁版嵁缁撴瀯绠$悊銆傛澶栵紝瀛愮▼搴忓拰鍔熻兘妯″潡鐨勫畾涔夊拰璋冪敤涔熷崄鍒嗘柟渚匡紝瀛愮▼搴忎箣闂村彲浠ラ氳繃鍙傛暟杩涜鐏垫椿浼犻掞紝...
绛旓細Input Help/Check鐣岄潰涓昏鍖呭惈鍑犱釜缁勬垚閮ㄥ垎锛鏁版嵁鍏冪礌(Data Element)锛氬畠鏄疭AP鏁版嵁瀛楀吀鐨勫熀纭鍏冪礌锛岀敤浜庡畾涔夊瓧娈靛睘鎬у拰鏁版嵁绫诲瀷銆備緥濡傦紝涓哄鎴风紪鍙峰瓧娈碉紙KUNNR锛夋寚瀹欿UNNR鏁版嵁鍏冪礌锛岀‘淇濆瓧娈典竴鑷存с傚閿(Foreign Key)锛氬畾涔夎〃闂村叧绯伙紝濡俈BAK琛ㄤ腑鐨凨UNNR瀛楁閫氳繃澶栭敭鍏宠仈KNA1琛ㄧ殑KUNNR锛岀‘淇濇暟鎹湁鏁堟с傛...
绛旓細璧峰垵锛ABAP涓昏鐢盨AP寮鍙戣呯敤浜嶴AP R/3骞冲彴鐨勫紑鍙戙傜劧鑰岋紝瀹冪殑璁捐浣垮緱SAP鐢ㄦ埛涔熻兘鍒╃敤瀹冩潵鎵╁睍杞欢搴旂敤锛屽鍒涘缓鑷畾涔夋姤琛ㄥ拰鐣岄潰銆傚敖绠BAP缂栫▼鐩稿瀹规槗涓婃墜锛屼絾瀵逛簬绋嬪簭鍛樸佽繍缁翠汉鍛樺拰缃戠粶鎶鏈汉鍛樻潵璇达紝瀹冮渶瑕佷竴瀹氱殑缂栫▼鎶宸у拰鏁版嵁搴鐭ヨ瘑锛岀壒鍒槸闈㈠悜瀵硅薄璁捐鐨勭悊瑙c傚敖绠AP鍦1992骞村彂甯冧簡R/3锛屼絾ABAP...
绛旓細鍚勪釜妯″潡闂村父鐢ㄨ〃鐨勫叧鑱旀柟娉曡鐭ラ亾鍟婏紝涓嶅お娓呮鐨勫彲浠ヤ娇鐢ㄤ簨鍔′唬鐮丼QVI锛屽埄鐢ㄥ垱寤簈uery,杈撳叆浣犺鏌ヨ鐨勫嚑涓鏁版嵁搴撹〃锛屾湁鐩存帴鍏宠仈鍏崇郴鐨勭郴缁熻嚜鍔ㄤ細閾炬帴锛岃繖鏍峰氨鍙互鏌ュ埌澶氫釜琛ㄧ殑鍏宠仈瀛楁
绛旓細浣犲弬鑰鏁版嵁搴撹〃寤轰竴涓粨鏋勶紝姣斿鏁版嵁搴撹〃鏄 dbtab data:it_dbtab like table of dbtab.鍐嶆妸浣犲唴琛ㄧ殑鏁版嵁 鍐欏埌杩欎釜鍐呰〃閲岋紝姣斿鍐呰〃鏄痠t_tab loop it_tab.move-corr it_tab to it_dbtab.endloop.insert dbtab from table it_dbtab.杩欐牱灏卞彲浠ヤ簡 ...
绛旓細濡傛灉浣犺閾炬帴鐨勮〃涓嶆槸绯荤粺閲岄潰鐨勫ぇ琛紝鍙互鑰冭檻浣跨敤锛屽惁鍒欒鎱庨噸锛屽洜涓鸿繖涓鍙ヨ绠楃瑳鍗″皵涔樼Н锛岄摼鎺ョ殑琛ㄦ湁澶氬皯璁板綍鍏ㄧ粰涔樿捣鏉ヨ绠楄闂鏁扮殑~瀹炲湪涓嶈灏卞缓鍗佷釜鍐呰〃锛屾牸寮忚窡鏁版嵁搴撹〃鐩稿悓锛屽厛鎶婃暟鎹叏閮ㄦ媺鍒板唴琛ㄩ噷闈㈠啀杩涜璁$畻鍖归厤锛岃繖鏍峰氨蹇緢澶氾紝褰撶劧鏄惧緱绗ㄦ嫏浜嗭紝涓嶈繃瀹炵敤銆俰nner join杩欑鐪嬩技楂樼瀹炲垯闈炲父...