Abap code please
Hello all,
can experts of ABAP give me the following routine?
In the update rules, i have to add a routine to populate subtotal_6 key figure.
it should pick values as in subtotal_5 field if the distribution channel in the incoming records has a value "IN". Else, it should have same values as in subtotal_6.
the existing routine(standard) which i am using is as follows:
============
PROGRAM UPDATE_ROUTINE.
$$ begin of global - insert your declaration only below this line -
TABLES: ...
DATA: IN TYPE F,
OUT TYPE F,
DENOM TYPE F, "test
NUMER TYPE F.
Def. of 'credit-documents': following doc.categ. are 'credit docs'
reversal invoice (N)
credit memo (O)
internal credit memo (6)
Credit-documents are delivered with negative sign. Sign is switched
to positive to provide positive key-figures in the cube.
The combination of characteristics DE_CRED and DOC-CLASS provides
a comfortable way to distinguisch e.g. positive incoming orders or
order returns.
Def. der 'Soll-Dokumente': folgende Belegtypen sind 'Soll-Belege'
Storno Rechnung (N)
Gutschrift (O)
Interne Verrechn. Gutschr. (6)
Soll-Dokumente werden mit negativem Vorzeichen geliefert. Um die Kenn
zahlen positiv in den Cube zu schreiben, wird das Vorzeich. gedreht
Die Kombination der Merkmale DEB_CRED und DOC-CLASS gibt Ihnen die
Möglichkeit schnell z.B. zwischen Auftrags-Eingang oder Retouren zu
unterscheiden.
DATA: DEB_CRED(3) TYPE C VALUE 'NO6'.
constants: c_msgty_e value 'E'.
$$ end of global - insert your declaration only before this line -
FORM compute_data_field
TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring
USING COMM_STRUCTURE LIKE /BIC/CS2LIS_13_VDITM
RECORD_NO LIKE SY-TABIX
RECORD_ALL LIKE SY-TABIX
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
CHANGING RESULT LIKE /BI0/V0SD_C03T-SUBTOT_1S
RETURNCODE LIKE SY-SUBRC
ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
$$ begin of routine - insert your code only below this line -
fill the internal table "MONITOR", to make monitor entries
DATA: VALUE LIKE COMM_STRUCTURE-NETVAL_INV.
DATA: US_RATE_TYPE LIKE COMM_STRUCTURE-RATE_TYPE.
CLEAR RESULT.
IF COMM_STRUCTURE-BILL_RULE CA '45'.
RETURNCODE = 4.
EXIT.
ENDIF.
IF NOT COMM_STRUCTURE-SUBTOTAL_1 IS INITIAL AND
COMM_STRUCTURE-DOC_CURRCY NE COMM_STRUCTURE-STAT_CURR.
US_RATE_TYPE = COMM_STRUCTURE-RATE_TYPE.
IF US_RATE_TYPE EQ SPACE.
US_RATE_TYPE = 'M'.
ENDIF.
ENDIF.
IF COMM_STRUCTURE-DOC_CURRCY NE COMM_STRUCTURE-STAT_CURR.
CALL FUNCTION 'CONVERT_TO_STAT_CURRENCY'
EXPORTING
DATE = COMM_STRUCTURE-ST_UP_DTE
DOCUMENT_AMOUNT = COMM_STRUCTURE-SUBTOTAL_1
DOCUMENT_CURRENCY = COMM_STRUCTURE-DOC_CURRCY
LOCAL_CURRENCY = COMM_STRUCTURE-LOC_CURRCY
STAT_CURRENCY = COMM_STRUCTURE-STAT_CURR
LOCAL_RATE = COMM_STRUCTURE-EXRATE_ACC
STAT_RATE = COMM_STRUCTURE-EXCHG_STAT
LOCAL_TYPE_OF_RATE = US_RATE_TYPE
STAT_TYPE_OF_RATE = US_RATE_TYPE
IMPORTING
STATISTICAL_AMOUNT = VALUE
EXCEPTIONS
LOCAL_RATE_NOT_FOUND = 1
STAT_RATE_NOT_FOUND = 2.
CASE SY-SUBRC.
WHEN 0.
RESULT = VALUE.
RETURNCODE = 0.
WHEN 1.
CLEAR MONITOR.
MONITOR-msgno = '005'.
MONITOR-msgid = 'SDBW'.
MONITOR-msgty = c_msgty_e.
MONITOR-msgv1 = COMM_STRUCTURE-BILL_NUM.
MONITOR-msgv2 = COMM_STRUCTURE-ST_UP_DTE.
MONITOR-msgv3 = COMM_STRUCTURE-DOC_CURRCY.
MONITOR-msgv4 = COMM_STRUCTURE-LOC_CURRCY.
append MONITOR.
RETURNCODE = 4.
WHEN 2.
CLEAR MONITOR.
MONITOR-msgno = '006'.
MONITOR-msgid = 'SDBW'.
MONITOR-msgty = c_msgty_e.
MONITOR-msgv1 = COMM_STRUCTURE-BILL_NUM.
MONITOR-msgv2 = COMM_STRUCTURE-ST_UP_DTE.
MONITOR-msgv3 = COMM_STRUCTURE-DOC_CURRCY.
MONITOR-msgv4 = COMM_STRUCTURE-STAT_CURR.
append MONITOR.
RETURNCODE = 4.
ENDCASE.
ELSE.
RESULT = COMM_STRUCTURE-SUBTOTAL_1.
ENDIF.
IF COMM_STRUCTURE-DOC_CATEG CA DEB_CRED.
RESULT = RESULT * ( -1 ).
ENDIF.
$$ end of routine - insert your code only before this line -
ENDFORM.
=============
Hello,
thanks srini. i added the code specified by you in the update routine. But it goes in a indefinate loop and remains in the yellow state in the monitor.
till psa the data is loaded fine. though few records(20), it remains in a yellow state.
what is wrong?
following is the code:
================
DATA: DEB_CRED(3) TYPE C VALUE 'NO6'.
constants: c_msgty_e value 'E'.
$$ end of global - insert your declaration only before this line -
FORM compute_data_field
TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring
USING COMM_STRUCTURE LIKE /BIC/CS2LIS_13_VDITM
RECORD_NO LIKE SY-TABIX
RECORD_ALL LIKE SY-TABIX
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
CHANGING RESULT LIKE /BI0/V0SD_C03T-SUBTOT_6S
RETURNCODE LIKE SY-SUBRC
ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
$$ begin of routine - insert your code only below this line -
fill the internal table "MONITOR", to make monitor entries
DATA: VALUE LIKE COMM_STRUCTURE-SUBTOTAL_6.
DATA: US_RATE_TYPE LIKE COMM_STRUCTURE-RATE_TYPE.
CLEAR RESULT.
IF COMM_STRUCTURE-BILL_RULE CA '45'.
RETURNCODE = 4.
EXIT.
ENDIF.
IF NOT COMM_STRUCTURE-SUBTOTAL_6 IS INITIAL AND
COMM_STRUCTURE-DOC_CURRCY NE COMM_STRUCTURE-STAT_CURR.
US_RATE_TYPE = COMM_STRUCTURE-RATE_TYPE.
IF US_RATE_TYPE EQ SPACE.
US_RATE_TYPE = 'M'.
ENDIF.
ENDIF.
IF COMM_STRUCTURE-DOC_CURRCY NE COMM_STRUCTURE-STAT_CURR.
CALL FUNCTION 'CONVERT_TO_STAT_CURRENCY'
EXPORTING
DATE = COMM_STRUCTURE-ST_UP_DTE
DOCUMENT_AMOUNT = COMM_STRUCTURE-SUBTOTAL_6
DOCUMENT_CURRENCY = COMM_STRUCTURE-DOC_CURRCY
LOCAL_CURRENCY = COMM_STRUCTURE-LOC_CURRCY
STAT_CURRENCY = COMM_STRUCTURE-STAT_CURR
LOCAL_RATE = COMM_STRUCTURE-EXRATE_ACC
STAT_RATE = COMM_STRUCTURE-EXCHG_STAT
LOCAL_TYPE_OF_RATE = US_RATE_TYPE
STAT_TYPE_OF_RATE = US_RATE_TYPE
IMPORTING
STATISTICAL_AMOUNT = VALUE
EXCEPTIONS
LOCAL_RATE_NOT_FOUND = 1
STAT_RATE_NOT_FOUND = 2.
CASE SY-SUBRC.
WHEN 0.
RESULT = VALUE.
RETURNCODE = 0.
WHEN 1.
CLEAR MONITOR.
MONITOR-msgno = '005'.
MONITOR-msgid = 'SDBW'.
MONITOR-msgty = c_msgty_e.
MONITOR-msgv1 = COMM_STRUCTURE-BILL_NUM.
MONITOR-msgv2 = COMM_STRUCTURE-ST_UP_DTE.
MONITOR-msgv3 = COMM_STRUCTURE-DOC_CURRCY.
MONITOR-msgv4 = COMM_STRUCTURE-LOC_CURRCY.
append MONITOR.
RETURNCODE = 4.
WHEN 2.
CLEAR MONITOR.
MONITOR-msgno = '006'.
MONITOR-msgid = 'SDBW'.
MONITOR-msgty = c_msgty_e.
MONITOR-msgv1 = COMM_STRUCTURE-BILL_NUM.
MONITOR-msgv2 = COMM_STRUCTURE-ST_UP_DTE.
MONITOR-msgv3 = COMM_STRUCTURE-DOC_CURRCY.
MONITOR-msgv4 = COMM_STRUCTURE-STAT_CURR.
append MONITOR.
RETURNCODE = 4.
ENDCASE.
ELSE.
RESULT = COMM_STRUCTURE-SUBTOTAL_6.
ENDIF.
CODE ADDED BY ME.......
IF COMM_STRUCTURE-DISTR_CHAN = 'IN'.
RESULT = COMM_STRUCTURE-SUBTOTAL_5.
ELSE.
RESULT = COMM_STRUCTURE-SUBTOTAL_6.
ENDIF.
IF COMM_STRUCTURE-DOC_CATEG CA DEB_CRED.
RESULT = RESULT * ( -1 ).
ENDIF.
$$ end of routine - insert your code only before this line -
ENDFORM.
Similar Messages
-
Help in ABAP code please!
We have upgraded to ECC6.0 and I am trying to fix some syntax errors. Here is the piece of code with the problem:
====
import i_key
old_zsops to old_zzsops
new_zsops to new_zzsops
from database zsopshist(Z1)
id i_key.
import i_key
old_zsops to old_prezsops
new_zsops to new_prezsops
from database zsopshist(Z1)
id i_key.
=====
I am kind of new to ABAP and went throught the documentation but could someone please tell me what "old_zsops to old_zzsops" does?
The code above is causing the dump with error "Error when attempting to IMPORT object "OLD_ZSOPS"". I went through the code and I found that old_zsops and new_zsops is not declared at all and it doesn't give any compilation errors! It goes to dump when I execute the problem. If it is required I would send the whole code but I see the following declarations in the code:
data: old_prezsops like zsops_prev. "PJCHG10854
data: new_prezsops like zsops_prev. "PJCHG10854
data: old_zzsops like zsops. "PJCHG10854
data: new_zzsops like zsops. "PJCHG10854
data: long_rec(900) type c. "PJCHG10854
data: old_lzsops like long_rec. "PJCHG10854
data: new_lzsops like long_rec. "PJCHG10854
data: curr_zsops like zsops,
prev_zsops like zsops_prev.
Could someone please help me how to fix this problem? How do I declare "old_zsops and new_zsops" because they are used in 2 different import statements? All the answers will be rewarded.
Thanks.
MithunEverything is in the same porgram. To avoid confusion I will send the whole code:
===
REPORT ZCFICO6010
line-count 65
line-size 132
no standard page heading.
tables: zsopshist, zsops.
*data: old_zsops like zsops,
new_zsops like zsops.
data: old_prezsops like zsops_prev. "PJCHG10854
data: new_prezsops like zsops_prev. "PJCHG10854
data: old_zzsops like zsops. "PJCHG10854
data: new_zzsops like zsops. "PJCHG10854
data: long_rec(900) type c. "PJCHG10854
data: old_lzsops like long_rec. "PJCHG10854
data: new_lzsops like long_rec. "PJCHG10854
data: curr_zsops like zsops,
prev_zsops like zsops_prev.
data: begin of i_key,
kostl(5),
aedat(8),
cputm(6).
data: end of i_key.
DATA: HEADER like zsops-oprcd,
header1(92) type c.
header1 like header.
data: v_field(18) type c,
v_old(20) type c,
v_new(20) type c,
user like zsops-uname,
date like zsops-aedtm.
data: begin of table occurs 0,
text(20) type c,
oprcd like zsops-oprcd,
field(15) type c,
user like zsops-uname,
date like zsops-aedtm,
v_old(20) ,
v_new(20) ,
end of table.
data: text(30) type c.
data: begin of itab occurs 0,
srtfd like zsopshist-srtfd,
end of itab.
*data: ihist like old_zsops occurs 0 with header line,
nhist like new_zsops occurs 0 with header line.
data: ihist like zsops occurs 0 with header line,
nhist like zsops occurs 0 with header line.
*& Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK one WITH FRAME TITLE TEXT-200.
parameters: s_oprcd like zsops-oprcd obligatory,
s_oprcdh like zsops-oprcd .
s_cputm for sy-uzeit.
SELECTION-SCREEN END OF BLOCK one.
SELECTION-SCREEN BEGIN OF BLOCK three WITH FRAME TITLE TEXT-300.
parameters:s_aedtm like zsops-aedtm obligatory,
s_aedtmh like zsops-aedtm obligatory.
SELECTION-SCREEN END OF BLOCK three.
SELECTION-SCREEN BEGIN OF BLOCK TWO WITH FRAME TITLE TEXT-100.
PARAMETERS: P_REGSRT RADIOBUTTON GROUP RADI,
P_ACCSRT RADIOBUTTON GROUP RADI.
SELECTION-SCREEN END OF BLOCK TWO.
parameters: new_date like sy-datum obligatory default '20051214'.
*& Top-Of-Page
top-of-page.
BEGIN OF BLOCK INSERTED FOR "JJMM20040330
DATA: CC_LOW LIKE ZSOPS-OPRCD,
CC_HIGH LIKE ZSOPS-OPRCD,
FROM_DATE(10) TYPE C,
TO_DATE(10) TYPE C.
WRITE: S_OPRCD TO CC_LOW NO-ZERO,
S_AEDTM TO FROM_DATE USING EDIT MASK '__/__/____',
S_AEDTMH TO TO_DATE USING EDIT MASK '__/__/____'.
IF S_OPRCDH = S_OPRCD.
CONCATENATE: 'Cost Center'(T02) CC_LOW 'Changed On'(T04) FROM_DATE
'To'(T03) TO_DATE 'Sort By'(T05) text INTO HEADER1
separated by space.
ELSE.
WRITE: S_OPRCDH TO CC_HIGH NO-ZERO.
CONCATENATE: 'Cost Center'(T02) CC_LOW 'To'(T03) CC_HIGH
'Changed On'(T04) FROM_DATE 'To'(T03) TO_DATE
'Sort By'(T05) text INTO HEADER1 separated by space.
ENDIF.
END OF BLOCK INSERTED FOR "JJMM20040330
PERFORM DISPLAY_PAGE_HEADER(ZCLT0001) USING
header1 "JJMM20040330
HEADER
TEXT-T01
header1. "JJMM20040330
BEGIN OF BLOCK COMMENTED OUT FOR "JJMM20040330
write:/5 'Cost Center'(T02), s_oprcd+5(5), 'To'(T03), s_oprcdh,
40 'Changed On'(T04), s_aedtm, 'To'(T03), s_aedtmh,
85 'Sort by'(T05), text.
uline. skip.
END OF BLOCK COMMENTED OUT FOR "JJMM20040330
Write:/ 'Field Changed'(C01), 25 'Old Values'(C02),
55 'New Values'(C03), 85 'Cost Center'(C04),
105 'Changed By'(C05), 120 'Changed On'(C06).
uline.
start-of-selection.
data: time(6),
v_subrc like sy-subrc,
prev_format(1),
srtfd like zsopshist-srtfd,
srtfdh like zsopshist-srtfd.
srtfd0(5) = s_oprcd5(5).
srtfd+5(8) = s_aedtm.
srtfd+13(6) = '000000'.
if s_oprcdh is initial.
s_oprcdh = s_oprcd.
endif.
srtfdh0(5) = s_oprcdh5(5).
srtfdh+5(8) = s_aedtmh.
srtfdh+13(6) = '999999'.
select srtfd from zsopshist into table itab
WHERE SRTFD >= SRTFD
AND SRTFD <= SRTFDH.
sort itab by srtfd.
loop at itab.
IF ITAB+5(8) GE S_AEDTM AND "IJHM00001
ITAB+5(8) LE S_AEDTMH. "IJHM00001
move: itab+0(5) to i_key-kostl,
itab+5(8) to i_key-aedat,
itab+13(6) to i_key-cputm.
/--- PJCHG10854 Begin commented/New code /
/--- To change the import structure based on date the old /
/--- import was removed and following coded added. /
clear: v_subrc, prev_format.
if itab+5(8) lt new_date.
prev_format = 'X'.
perform import_record_prev changing v_subrc. "PJCHG10854
else.
perform import_record changing v_subrc. "PJCHG10854
endif.
import i_key
old_zsops
new_zsops
from database zsopshist(Z1)
id i_key.
/--- PJCHG10854 END commented/New code /
if v_subrc = 0. "PJCHG10854
perform get_final_table.
endif.
ENDIF. "IJHM00001
endloop.
if p_regsrt = 'X'.
sort table by oprcd field date descending.
text = 'Cost Center'(C04).
else.
sort table by field oprcd date descending.
text = 'Field Changed'(C01).
endif.
perform write_report.
FORM get_final_table *
form get_final_table.
move old_zsops to ihist. "PJCHG10854
move new_zsops to nhist. "PJCHG10854
if prev_format eq 'X'. "PJCHG10854
move old_prezsops to ihist. "PJCHG10854
move new_prezsops to nhist. "PJCHG10854
else. "PJCHG10854
move old_zzsops to ihist. "PJCHG10854
move new_zzsops to nhist. "PJCHG10854
endif. "PJCHG10854
if ihist-ivcrg ne nhist-ivcrg.
table-text = 'Invst Charge Base'(F01).
table-field = 'IVCRG'.
table-v_old = ihist-ivcrg.
table-v_new = nhist-ivcrg.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
if ihist-mgtfp ne nhist-mgtfp.
table-field = 'MGTFP'.
table-text = 'Mgt Fee %'(F02).
table-v_old(12) = ihist-mgtfp.
table-v_new(12) = nhist-mgtfp.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
if ihist-discd ne nhist-discd.
table-field = 'DISCD'.
table-text = 'Cash Disc. Passback'(F03).
table-v_old = ihist-discd.
table-v_new = nhist-discd.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
if ihist-consc ne nhist-consc.
table-field = 'CONSC'.
table-text = 'Subsidy Calc'(F04).
table-v_old = ihist-consc.
table-v_new = nhist-consc.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
if ihist-payfart ne nhist-payfart.
table-field = 'PAYFART'.
table-text = 'Payroll Fringe'(F05).
table-v_old(12) = ihist-payfart.
table-v_new(12) = nhist-payfart.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
if ihist-frbpb ne nhist-frbpb.
table-field = 'FRBPB'.
table-text = 'Rebate Pass Back'(F06).
table-v_old(12) = ihist-frbpb.
table-v_new(12) = nhist-frbpb.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
if ihist-exlca ne nhist-exlca.
table-field = 'EXLCA'.
table-text = 'Excl Source27'(F07).
table-v_old = ihist-exlca.
table-v_new = nhist-exlca.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
perform write_report.
append table.
endif.
if ihist-exlcb ne nhist-exlcb.
table-field = 'EXLCB'.
table-text = 'Excl Source11'(F08).
table-v_old = ihist-exlcb.
table-v_new = nhist-exlcb.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
perform write_report.
append table.
endif.
if ihist-trnrate ne nhist-trnrate.
table-field = 'TRNRATE'.
table-text = 'Payroll Training'(F09).
table-v_old(12) = ihist-trnrate.
table-v_new(12) = nhist-trnrate.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
if ihist-mgffa ne nhist-mgffa.
table-field = 'MGFFA'.
table-text = 'Mgt Fee Amt'(F10).
table-v_old(12) = ihist-mgffa.
table-v_new(12) = nhist-mgffa.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
perform write_report.
append table.
endif.
if ihist-mgtfi ne nhist-mgtfi.
table-field = 'MGTFI'.
table-text = 'Mgt Fees Indicator'(F11).
table-v_old = ihist-mgtfi.
table-v_new = nhist-mgtfi.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
perform write_report.
append table.
endif.
if ihist-eqres ne nhist-eqres.
table-field = 'EQRES'.
table-text = 'Eqip Res Accrual'(F12).
table-v_old = ihist-eqres. "JJMM20040331
table-v_new = nhist-eqres. "JJMM20040331
table-v_old(12) = ihist-eqres. "JJMM20040331
table-v_new(12) = nhist-eqres. "JJMM20040331
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
if ihist-ovrhd ne nhist-ovrhd.
table-field = 'OVRHD'.
table-text = 'OverHead Amt'(F13).
table-v_old(12) = ihist-ovrhd.
table-v_new(12) = nhist-ovrhd.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
if ihist-xaccural ne nhist-xaccural.
table-field = 'XACCUARAL'.
table-text = 'Exclude Accrual'(F14).
table-v_old(12) = ihist-xaccural.
table-v_new(12) = nhist-xaccural.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
if ihist-ovrrt ne nhist-ovrrt.
table-field = 'OVRRT'.
table-text = 'OverHead Rate'(F15).
table-v_old(12) = ihist-ovrrt.
table-v_new(12) = nhist-ovrrt.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
if ihist-ztbd01 ne nhist-ztbd01.
table-field = 'ZTBD01'.
table-text = 'Char1'. "JJMM20040330
table-text = 'Meal Allowance'(F16). "JJMM20040330
table-v_old = ihist-ztbd01.
table-v_new = nhist-ztbd01.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
BEGIN OF BLOCK INSERTED FOR "JJMM20040330
if ihist-earlybil ne nhist-earlybil.
table-field = 'EARLYBIL'.
table-text = 'Early Billing'(F17).
table-v_old = ihist-earlybil.
table-v_new = nhist-earlybil.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
if ihist-combined ne nhist-combined.
table-field = 'COMBINED'.
table-text = 'Combined Billing'(F18).
table-v_old = ihist-COMBINED.
table-v_new = nhist-COMBINED.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
END OF BLOCK INSERTED FOR "JJMM20040330
if ihist-rate1 ne nhist-rate1.
table-field = 'RATE1'.
table-text = 'Rate 1'(F19).
table-v_old(12) = ihist-rate1.
table-v_new(12) = nhist-rate1.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
*if ihist-rate1 ne nhist-rate2. "JJMM20040330
table-field = 'RATE1'. "JJMM20040330
if ihist-rate2 ne nhist-rate2. "JJMM20040330
table-field = 'RATE2'. "JJMM20040330
table-text = 'Rate 2'(F20).
table-v_old(12) = ihist-rate2.
table-v_new(12) = nhist-rate2.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
*if ihist-rate1 ne nhist-rate3. "JJMM20040330
if ihist-rate3 ne nhist-rate3. "JJMM20040330
table-field = 'RATE3'.
table-text = 'Rate 3'(F21).
table-v_old(12) = ihist-rate3.
table-v_new(12) = nhist-rate3.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
*if ihist-rate1 ne nhist-rate4. "JJMM20040330
if ihist-rate4 ne nhist-rate4. "JJMM20040330
table-field = 'RATE4'.
table-text = 'Rate 4'(F22).
table-v_old(12) = ihist-rate4.
table-v_new(12) = nhist-rate4.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
*if ihist-rate1 ne nhist-rate5. "JJMM20040330
if ihist-rate5 ne nhist-rate5. "JJMM20040330
table-field = 'RATE5'.
table-text = 'Rate 5'(F23).
table-v_old(12) = ihist-rate5.
table-v_new(12) = nhist-rate5.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
*if ihist-rate1 ne nhist-rate6. "JJMM20040330
if ihist-rate6 ne nhist-rate6. "JJMM20040330
table-field = 'RATE6'.
table-text = 'Rate 6'(F24).
table-v_old(12) = ihist-rate6.
table-v_new(12) = nhist-rate6.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
*if ihist-rate1 ne nhist-rate7. "JJMM20040330
if ihist-rate7 ne nhist-rate7. "JJMM20040330
table-field = 'RATE7'.
table-text = 'Rate 7'(F25).
table-v_old(12) = ihist-rate7.
table-v_new(12) = nhist-rate7.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
*if ihist-rate1 ne nhist-rate8. "JJMM20040330
if ihist-rate8 ne nhist-rate8. "JJMM20040330
table-field = 'RATE8'.
table-text = 'Rate 8'(F26).
table-v_old(12) = ihist-rate8.
table-v_new(12) = nhist-rate8.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
*if ihist-rate1 ne nhist-rate9. "JJMM20040330
if ihist-rate9 ne nhist-rate9. "JJMM20040330
table-field = 'RATE9'.
table-text = 'Rate 9'(F27).
table-v_old(12) = ihist-rate9.
table-v_new(12) = nhist-rate9.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
*if ihist-rate1 ne nhist-rate10. "JJMM20040330
if ihist-rate10 ne nhist-rate10. "JJMM20040330
table-field = 'RATE10'.
table-text = 'Rate 10'(F28).
table-v_old(12) = ihist-rate10.
table-v_new(12) = nhist-rate10.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
*if ihist-rate1 ne nhist-rate11. "JJMM20040330
if ihist-rate11 ne nhist-rate11. "JJMM20040330
table-field = 'RATE11'.
table-text = 'Rate 11'(F29).
table-v_old(12) = ihist-rate11.
table-v_new(12) = nhist-rate11.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
perform write_report.
endif.
The following lines of code have been added per change IJHM00001
if ihist-rate12 ne nhist-rate12.
table-field = 'RATE12'.
table-text = 'Rate 12'(F30).
table-v_old(12) = ihist-rate12.
table-v_new(12) = nhist-rate12.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
if ihist-rate13 ne nhist-rate13.
table-field = 'RATE13'.
table-text = 'Rate 13'(F31).
table-v_old(12) = ihist-rate13.
table-v_new(12) = nhist-rate13.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
if ihist-rate14 ne nhist-rate14.
table-field = 'RATE14'.
table-text = 'Rate 14'(F32).
table-v_old(12) = ihist-rate14.
table-v_new(12) = nhist-rate14.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
if ihist-rate15 ne nhist-rate15.
table-field = 'RATE15'.
table-text = 'Rate 15'(F33).
table-v_old(12) = ihist-rate15.
table-v_new(12) = nhist-rate15.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
if ihist-rate16 ne nhist-rate16.
table-field = 'RATE16'.
table-text = 'Rate 16'(F34).
table-v_old(12) = ihist-rate16.
table-v_new(12) = nhist-rate16.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
if ihist-rate17 ne nhist-rate17.
table-field = 'RATE17'.
table-text = 'Rate 17'(F35).
table-v_old(12) = ihist-rate17.
table-v_new(12) = nhist-rate17.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
if ihist-rate18 ne nhist-rate18.
table-field = 'RATE18'.
table-text = 'Rate 18'(F36).
table-v_old(12) = ihist-rate18.
table-v_new(12) = nhist-rate18.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
The following lines of code have been added per change IJHM00002
if ihist-rate19 ne nhist-rate19.
table-field = 'RATE19'.
table-text = 'Rate 19'(F37).
table-v_old(12) = ihist-rate19.
table-v_new(12) = nhist-rate19.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
if ihist-rate20 ne nhist-rate20.
table-field = 'RATE20'.
table-text = 'Rate 20'(F38).
table-v_old(12) = ihist-rate20.
table-v_new(12) = nhist-rate20.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
if ihist-rate21 ne nhist-rate21.
table-field = 'RATE21'.
table-text = 'Rate 21'(F39).
table-v_old(12) = ihist-rate21.
table-v_new(12) = nhist-rate21.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
if ihist-rate22 ne nhist-rate22.
table-field = 'RATE22'.
table-text = 'Rate 22'(F40).
table-v_old(12) = ihist-rate22.
table-v_new(12) = nhist-rate22.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
if ihist-intcrb ne nhist-intcrb.
table-field = 'INTCRB'.
table-text = 'Intcrb'(F47). "IJHM00002
table-text = 'Intcrb'(F37). "IJHM00002
table-v_old = ihist-intcrb.
table-v_new = nhist-intcrb.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
if ihist-intcrr ne nhist-intcrr.
table-field = 'INTCRR'.
table-text = 'Intcrr'(F48). "IJHM00002
table-text = 'Intcrr'(F38). "IJHM00002
table-v_old(12) = ihist-intcrr.
table-v_new(12) = nhist-intcrr.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
if ihist-zwktran ne nhist-zwktran.
table-field = 'ZWKTRAN'.
table-text = 'Data Trans End Unit'(F49). "IJHM00002
table-text = 'Data Trans End Unit'(F39). "IJHM00002
table-v_old = ihist-zwktran.
table-v_new = nhist-zwktran.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
if ihist-zwkbud ne nhist-zwkbud.
table-field = 'ZWKBUD'.
table-text = 'Wkly Budget Ind'(F50). "IJHM00002
table-text = 'Wkly Budget Ind'(F40). "IJHM00002
table-v_old = ihist-zwkbud.
table-v_new = nhist-zwkbud.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
if ihist-bcycle ne nhist-bcycle.
table-field = 'BCYCLE'.
table-text = 'Bcycle'(F51). "IJHM00002
table-text = 'Bcycle'(F41). "IJHM00002
table-v_old = ihist-bcycle.
table-v_new = nhist-bcycle.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
if ihist-ovind ne nhist-ovind.
table-field = 'OVIND'.
table-text = 'Ovind'(F52). "IJHM00002
table-text = 'Ovind'(F42). "IJHM00002
table-v_old = ihist-ovind.
table-v_new = nhist-ovind.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
*New code for PRSID -
"ZN032106
if ihist-prsid ne nhist-prsid.
table-field = 'PRSID'.
table-text = 'PRSID'(F53).
table-v_old = ihist-prsid.
table-v_new = nhist-prsid.
table-user = nhist-uname.
table-date = nhist-aedtm.
table-oprcd = nhist-oprcd.
append table.
endif.
*End of new code----
"ZN032106
endform.
FORM write_report *
form write_report.
loop at table.
write:/1 table-text, 25 table-v_old(12) left-justified,
55 table-v_new(12) left-justified, 85 table-oprcd,
106 table-user, 120 table-date.
uline.
endloop.
skip 5. "JJMM20040330
write:/35 TEXT-R01. "JJMM20040330
reserve 1 lines. "JJMM20040330
endform.
*& Form import_record
form import_record changing p_subrc.
import i_key
old_zsops to old_zzsops
new_zsops to new_zzsops
from database zsopshist(Z1)
id i_key.
p_subrc = sy-subrc.
endform. " import_record
*& Form import_record_prev
form import_record_prev changing p_subrc.
import i_key
old_zsops to old_prezsops
new_zsops to new_prezsops
from database zsopshist(Z1)
id i_key.
p_subrc = sy-subrc.
endform. " import_record_prev
*& Form import_record_long
form import_record_long changing p_subrc.
import i_key
old_zsops to old_lzsops
new_zsops to new_lzsops
from database zsopshist(Z1)
id i_key.
p_subrc = sy-subrc.
endform. " import_record_prev
========
Thanks.
Mithun -
ABAP Code Problem in Start Routine to Fill the value from Look-up Table ???
Hi all,
I am trying to fill the values of DOC_NUMBER & PLANT from look-up table /BIC/AZSD_O0700 (Billing Item ODS) for each BILL_NUM in Start Routine for Update Rules of Billing Header ODS and modify the data_package.
What is wrong with the below ABAP code, PLEASE ???
data: it_data type standard table of data_package_structure
with header line
with non-unique default key initial size 0.
types: begin of billing_item_type,
BILL_NUM like /BIC/AZSD_O0700-BILL_NUM,
DOC_NUMBER like /BIC/AZSD_O0700-DOC_NUMBER,
PLANT like /BIC/AZSD_O0700-PLANT,
end of billing_item_type.
refresh it_data.
clear it_data.
it_data[] = DATA_PACKAGE[].
refresh DATA_PACKAGE.
clear DATA_PACKAGE.
loop at it_data.
select DOC_NUMBER PLANT into (it_data-DOC_NUMBER, it_data-PLANT)
from /BIC/AZSD_O0700
where BILL_NUM = it_data-BILL_NUM
and FISCVARNT = it_data-fiscvarnt.
endselect.
if sy-subrc = 0.
move-corresponding it_data to DATA_PACKAGE.
endif.
endloop.
modify DATA_PACKAGE.
Thanks,
Venkat.Hi Venkat,
Two things -One is the performance and the other ... there is no Append within the loop.
Try moving the select statement ousdie the loop to improve performance and move the modify statement into the loop ... change modify to append. Code below.
Let me know if you need more help.
Best regards,
Kazmi
data: it_data type standard table of data_package_structure
with header line
with non-unique default key initial size 0.
types: begin of billing_item_type,
BILL_NUM like /BIC/AZSD_O0700-BILL_NUM,
DOC_NUMBER like /BIC/AZSD_O0700-DOC_NUMBER,
PLANT like /BIC/AZSD_O0700-PLANT,
end of billing_item_type.
refresh it_data.
clear it_data.
it_data] = DATA_PACKAGE[.
refresh DATA_PACKAGE.
clear DATA_PACKAGE.
loop at it_data.
select DOC_NUMBER PLANT into (it_data-DOC_NUMBER, it_data-PLANT)
from /BIC/AZSD_O0700
where BILL_NUM = it_data-BILL_NUM
and FISCVARNT = it_data-fiscvarnt.
endselect.
if sy-subrc = 0.
move-corresponding it_data to DATA_PACKAGE.
Append DATA_PACKAGE.
endif.
endloop. -
Enhancing 0FI_GL_4 - ABAP code is NOT working - URGENT PLEASE ???
Hi all,
I want to enhance 0FI_GL_4 extractor with CHECT, RWBTR & PRIDT from PAYR table if VBELN of 0FI_GL_4 is not BLANK, with the following conditions:
1.Load all the records of PAYRQ table into PAYRQ internal table LT_PAYRQ
with matching BELNR, AUGBL & BUKRS from I_DTFIGL_4 internal table.
2.Load all the records of PAYR table into PAYR internal table LT_PAYR
with matching AUGBL & BUKRS from LT_PAYRQ internal table.
3.Read PAYR internal table LT_PAYR with matching BELNR (from I_DTFIGL_4
internal table) and fill the new fields CHECT, RWBTR & PRIDT.
The following the is ABAP code, but it is NOT working:
DATA:I_DTFIGL_4 LIKE DTFIGL_4 OCCURS 0 WITH HEADER LINE,
L_TABIX LIKE SY-TABIX.
DATA: BEGIN OF LS_PAYRQ,
ZBUKR LIKE PAYRQ-ZBUKR,
BELNR LIKE PAYRQ-BELNR,
AUGBL LIKE PAYRQ-AUGBL,
END OF LS_PAYRQ.
DATA: LT_PAYRQ LIKE LS_PAYRQ OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF LS_PAYR,
VBLNR LIKE PAYR-VBLNR,
CHECT LIKE PAYR-CHECT,
RWBTR LIKE PAYR-RWBTR,
PRIDT LIKE PAYR-PRIDT,
END OF LS_PAYR.
DATA: LT_PAYR LIKE LS_PAYR OCCURS 0 WITH HEADER LINE.
WHEN '0FI_GL_4'.
I_DTFIGL_4 = C_T_DATA.
SELECT BELNR AUGBL ZBUKR
FROM PAYRQ
INTO CORRESPONDING FIELDS OF TABLE LT_PAYRQ
FOR ALL ENTRIES IN I_DTFIGL_4
WHERE BELNR = I_DTFIGL_4-BELNR
AND AUGBL = I_DTFIGL_4-AUGBL
AND BUKRS = I_DTFIGL_4-BUKRS.
SORT LT_PAYRQ BY BELNR.
SELECT VBLNR CHECT RWBTR PRIDT
FROM PAYR
INTO CORRESPONDING FIELDS OF TABLE LT_PAYR
FOR ALL ENTRIES IN LT_PAYRQ WHERE VBLNR = LT_PAYRQ-AUGBL
AND ZBUKR = LT_PAYRQ-ZBUKR.
SORT LT_PAYR BY VBLNR.
LOOP AT C_T_DATA INTO I_DTFIGL_4.
L_TABIX = SY-TABIX.
IF NOT I_DTFIGL_4-VBELN IS INITIAL. " IF BILLING DOCUMENT EXISTS
READ TABLE LT_PAYR WITH KEY VBLNR = I_DTFIGL_4-BELNR.
IF SY-SUBRC = 0.
MOVE LT_PAYR-CHECT TO I_DTFIGL_4-ZZCHECT.
MOVE LT_PAYR-RWBTR TO I_DTFIGL_4-ZZRWBTR.
MOVE LT_PAYR-PRIDT TO I_DTFIGL_4-ZZPRIDT.
MODIFY C_T_DATA FROM I_DTFIGL_4 INDEX L_TABIX.
ENDIF.
CLEAR:I_DTFIGL_4-ZZCHECT,I_DTFIGL_4-ZZRWBTR,I_DTFIGL_4-ZZPRIDT,
LT_PAYR, LT_PAYRQ.
ENDIF.
ENDLOOP.
Could you please find the problem with above ABAP code and correct it.
Since I want to enhance it, if VBELN is not Blank and do I have to move the IF condition (I_DTFIGL_4-VBELN IS INITIAL) to another location for better performance.
Thanks,
Venkat..Dear Gajesh,
Please accept my thanks for your Spontaneous reply.
Selection Screen data is given below.
1 --> Material Number
2 --> Inspection Lot Number
3 --> Date of Lot Creation
4--> Inspection Type
Normally the clint will give the Inspection Type ie 4th input and Date of Lot creation ie 3rd Input (Range of Date).
Please do the needful.
With Best Regards,
Raghu Sharma -
Creating an xml file from abap code
Hello All,
Please let me know which FM do I need to execute in order to create an XML file from my ABAP code ?
Thanks in advance,
Paul.This has been discussed before
XML files from ABAP programs -
Needs sample ABAP code for field routine
Dear Expert,
There is a field "Pay Scale Group" in my DSO which stores the data in the format
AA1/B1/CCC2/DD2/EEE1, A1/BB2/CC2/DDD3/EE2 etc. These data has to be transferred to
InfoCube where "pay Scale Group" in the InfoCube will store the data like EEE1,EE2 etc.
I need to write a field routine on the transformation between DSO and Cube.
Can any one please help me with the sample ABAP code for this scenario.
Some more examples for better understanding of the requirement:-
Data in DSO(Source) Data in Cube(Target)
=================== ===================
AA1/B1/CCC2/DD2/EEE1 EEE1
AAA1/BB2/CC1/DDD3/EE2 EE2
A2/BBB2/CC2/DDD3/EEE5 EEE5
AA2/BB1/C1/DDD3/EE3 EE3
A3/B1/CC2/DDD1/EE4 EE4
Many thanks in advance.
Regards,
Prakash
Please do not dump your code requirements in SDN
Edited by: Pravender on May 18, 2011 11:37 AMHi,
You can use the following code :
Suppose the technical name of the field coming from DSO is ZPAY_SGRP.
And also for example let me take one record, that is ZPAY_SGRP = AA1/B1/CCC2/DD2/EEE1 .
My assumption is that there will always be 4 '/'.
In the field routine write the below code
data: V1(5) type c,
V2(5) type c,
V3(5) type c,
V4(5) type c,
V5(5) type c.
data : VAR1 TYPE /BIC/OIZPAY_SGRP.
split VAR 1 at '/' into V1 V2 V3 V4 V5.
result = V5.
V5 will be having the characters after the last '/' .That is V5 = EEE1.
Hope the above reply was helpful.
Kind Regards,
Ashutosh Singh
Edited by: Ashutosh Singh on May 17, 2011 3:53 PM
Edited by: Ashutosh Singh on May 17, 2011 4:17 PM -
Sample ABAP code for userexits, and calling bapi's
Hi,
Can someone please send me sample ABAP code
1) to do extractor enhancement using user exit.
2) ABAP program to call BAPI to read live cache order series data in SNP and write to Idocs through some ports.
3) ABAP routine to generate file name (based on date/country)in the infopackage to upload flatfiles.
Thank you very much in advance and appreciate any help.
Regards
Prasadhai ,
check this code...
*& Tables
tables : tstc, "SAP Transaction Codes
tadir, "Directory of Repository Objects
modsapt, "SAP Enhancements - Short Texts
modact, "Modifications
trdir, "System table TRDIR
tfdir, "Function Module
enlfdir, "Additional Attributes for Function Modules
tstct. "Transaction Code Texts
*& Variables
data : jtab like tadir occurs 0 with header line.
data : field1(30).
data : v_devclass like tadir-devclass.
*& Selection Screen Parameters
selection-screen begin of block a01 with frame title text-001.
selection-screen skip.
parameters : p_tcode like tstc-tcode obligatory.
selection-screen skip.
selection-screen end of block a01.
*& Start of main program
start-of-selection.
Validate Transaction Code
select single * from tstc
where tcode eq p_tcode.
Find Repository Objects for transaction code
if sy-subrc eq 0.
select single * from tadir
where pgmid = 'R3TR'
and object = 'PROG'
and obj_name = tstc-pgmna.
move : tadir-devclass to v_devclass.
if sy-subrc ne 0.
select single * from trdir
where name = tstc-pgmna.
if trdir-subc eq 'F'.
select single * from tfdir
where pname = tstc-pgmna.
select single * from enlfdir
where funcname = tfdir-funcname.
select single * from tadir
where pgmid = 'R3TR'
and object = 'FUGR'
and obj_name = enlfdir-area.
move : tadir-devclass to v_devclass.
endif.
endif.
Find SAP Modifactions
select * from tadir
into table jtab
where pgmid = 'R3TR'
and object = 'SMOD'
and devclass = v_devclass.
select single * from tstct
where sprsl eq sy-langu
and tcode eq p_tcode.
format color col_positive intensified off.
write:/(19) 'Transaction Code - ',
20(20) p_tcode,
45(50) tstct-ttext.
skip.
if not jtab[] is initial.
write:/(95) sy-uline.
format color col_heading intensified on.
write:/1 sy-vline,
2 'Exit Name',
21 sy-vline ,
22 'Description',
95 sy-vline.
write:/(95) sy-uline.
loop at jtab.
select single * from modsapt
where sprsl = sy-langu and
name = jtab-obj_name.
format color col_normal intensified off.
write:/1 sy-vline,
2 jtab-obj_name hotspot on,
21 sy-vline ,
22 modsapt-modtext,
95 sy-vline.
endloop.
write:/(95) sy-uline.
describe table jtab.
skip.
format color col_total intensified on.
write:/ 'No of Exits:' , sy-tfill.
else.
format color col_negative intensified on.
write:/(95) 'No User Exit exists'.
endif.
else.
format color col_negative intensified on.
write:/(95) 'Transaction Code Does Not Exist'.
endif.
Take the user to SMOD for the Exit that was selected.
at line-selection.
get cursor field field1.
check field1(4) eq 'JTAB'.
set parameter id 'MON' field sy-lisel+1(10).
call transaction 'SMOD' and skip first screen. -
ABAP code for BI 7.0 transformations start routine
Hi all,
I am trying to update data from DSO1 (Source1: transaction data) to Infocube(TARGET)
In the transformations Start routine, I have to read DSO2(Source2: Master data) for some fields.
DSO1 has CUSTOMER as part of key
DSO2 has CUSTOMER (key) and other fields....FIELD1, FILED2, FIELD3
Infocube to be updated with FIELDS1,2 & 3 WHILE READING DSO2.
WHERE DSO1 CUSTOMER matches with DSO2 CUSTOMER.
Also, data NOT TO BE UPLOADED into Infocube if FIELD1 in DSO2= NULL
Please give me the abap code for the above logic.
Appreciate any help in this regard.
Thanks.This is a doc from this site:
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6090a621-c170-2910-c1ab-d9203321ee19
Ravi Thothadri -
ABAP code needed to convert from 0calmonth2 & 0calyear to 0calmonth
Hi SAP GURUS,
Can anybody give me the ABAP code to convert from 0calmonth2 and 0calyear to 0calmonth.and please suggest me whether i have to write start routine or end routine in transformations.
Thanks ALL.hi,
in the transformation map 0calmonth2 and 0calyear to the 0calmonth field, and from drop down choose routine.
there will be an area where it will be mentioned write your piece of code below this line.
paste the below code:
Concatenate source_fields-0calmonth2 source_fields-0calyear into result.
also delete the line result = .
save the routine and execute the package.
regards,
Arvind. -
Enhancement-ABAP Code-Customized Field issue
Hi Experts,
Currently I am working on the BW3.5 version. We are using the standard SRM standard extractor 0BBP_TD_SC_1 and we enhance same extractor(populate the filed through CMOD - ABAP Code) with one customized field also. We are having issue on the customized field data which post from SRM system. I have verified the field value and value is fine in RSA3 in SRM source system. But while posting into the BW(PSA itself), its loading correct & wrong value. When i check the PSA for the particular load, It looks little strange. In the PSA, I can see correct value on my first record of the same SC and then next records has incorrect value of the same SC. Currently I am using the ODS as a data target. So finally i am getting the incorrect value on the customized field.
Ex Scenario:
Ex Customized Field: ZORGID
In SRM source system RSA3 Extractor Checker value:
Shopping Card No: 100
Customized Field: ZORGID=1
Shopping Card No: 200
Customized Field: ZORGID=2
In BW posting-PSA:
Shopping Card No: 100
Customized Field: ZORGID=2
Shopping Card No: 200
Customized Field: ZORGID=2
At the same time, if i do the selective deletion of the particular Shopping Card or group of SC in BW and do the full repair, then it gets a correct ZORGID=1 for the same Shopping Card.
I strongly believe, something wrong in the ABAP code. But when we tried to debug the customized filed value in RSA3. The value is fine. so we unable to trace out the issue. Please help me to fix the code. Thanks in advance.
CMOD ABAP Code:
*Populate approver ID even though it doesn't require approval this is required to make sure BW reports have restrict access to respective Org Unit approvals only
IF l_s_bbp_sc-approver_id IS INITIAL AND l_s_bbp_sc-itm_guid IS NOT INITIAL.
CALL FUNCTION 'Z_BBP_FIRST_APPROVALGET'
EXPORTING
iv_header_guid = l_s_bbp_sc-guid
iv_itm_guid = l_s_bbp_sc-itm_guid
IMPORTING
approver_no = l_s_bbp_sc-approver_id
EXCEPTIONS
no_data = 1
OTHERS = 2
IF sy-subrc 0.
ENDIF.
ENDIF.
To ensure that the Org Unit passed in into the field
l_s_bbp_sc-zzapprov_orgunit belongs to the Actual Level 1
Budget Owner and not any other manager such as Added Approver.
CLEAR : ls_ln_approvers, l_userid, lv_bpartner_guid.
DATA : lv_f_apprv_part TYPE BU_PARTNER.
READ TABLE lt_ln_approvers INTO ls_ln_approvers
WITH KEY INITIAL_INDEX = '0000000001'.
IF sy-subrc EQ 0.
MOVE ls_ln_approvers-approval_agent+2(12) TO l_userid.
CALL FUNCTION 'BP_CENTRALPERSON_GET'
EXPORTING
iv_username = l_userid
IMPORTING
ev_bu_partner_guid = lv_bpartner_guid
EXCEPTIONS
no_central_person = 1
no_business_partner = 2
no_id = 3
OTHERS = 4.
IF sy-subrc = 0.
CALL FUNCTION 'BUPA_NUMBERS_GET'
EXPORTING
iv_partner_guid = lv_bpartner_guid
IMPORTING
ev_partner = lv_f_apprv_part.
ENDIF.
ENDIF.
We get the BP number of the first Budget Owner 1
Here, we superseed the field l_s_bbp_sc-approver_id
whereby it may be wrong due to Added Approver.
IF l_s_bbp_sc-approver_id IS NOT INITIAL.
IF lv_f_apprv_part IS NOT INITIAL.
IF l_s_bbp_sc-itm_guid IS NOT INITIAL.
CALL FUNCTION 'RH_STRUC_GET'
EXPORTING
act_otype = 'BP'
act_objid = lv_f_apprv_part
act_wegid = 'EBP-UP'
act_begda = sy-datum
act_endda = sy-datum
act_tdepth = 4
TABLES
result_tab = lt_result_tab
EXCEPTIONS
no_plvar_found = 1
no_entry_found = 2
OTHERS = 3
IF sy-subrc = 0.
READ TABLE lt_result_tab INTO ls_result_tab WITH KEY
otype = 'O'.
IF sy-subrc EQ 0.
l_s_bbp_sc-zzapprov_orgunit = ls_result_tab-objid.
ELSE.
ENDIF.
ENDIF.
ENDIF.
Thanks,
RRHi Experts,
Any suggestions. Thanks.
Thanks,
RR -
IDOC: How to create child segment with abap code.
Hi,
I'am trying to write an abap code to create segments for an Idoc which structure is the following:
ZLE_00060_DLVY
> E1EDL20
> Z1DEL_CONS
>Z1DEL_MAT_HEADER
> Z1DEL_MAT
> E1EDL20RET2
> E1EDL22
> E1EDL21
> E1EDL23
> E1EDL51
I receive a sintax error: Error in IDoc with status 26 .
Checking the result I note all segment at the same level and an error about the segment E1EDL22
EDI: Syntax error in IDoc (segment cannot be identified)
Message no. E0078
Diagnosis
The segment E1EDL22 does not occur at the current level of the basic
type DELVRY05 (extension ZLE_00060_DLVY).
This error can have several reasons:
o The segment E1EDL22 is assigned to a group whose header segment does
not occur.
o The segment E1EDL22 does not exist in the syntax description of the
basic type DELVRY05 (extension ZLE_00060_DLVY).
o The sequence of segments in the group in which the segment appears
is incorrect.
Previous errors ('mandatory' segment or group missing) may be due to
this error.
Procedure
Please check the IDoc or the syntax description of the basic type
DELVRY05 (extension ZLE_00060_DLVY).
After the error I have:
data records
E1EDL20
Z1DEL_CONS
Z1DEL_MAT_HEADER
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
Z1DEL_MAT
E1EDL20RET2
E1EDL22
E1EDL21
Abap code:
idoc_data-segnam = 'Z1DEL_CONS'.
idoc_data-sdata = s_z1del_cons.
append idoc_data.
idoc_data-segnam = 'Z1DEL_MAT_HEADER'.
s_z1del_mat_header-tsegment = 'MATERIAL'.
idoc_data-sdata = s_z1del_mat_header.
append idoc_data.
clear idoc_data-sdata. <<<<<<<<<<< how to indent the structure because this is a child.
idoc_data-sdata = s_Z1DEL_MAT.
idoc_data-segnam = 'Z1DEL_MAT'.
append idoc_data.
idoc_data-segnam = 'E1EDL20RET2'.
idoc_data-sdata = s_E1EDL20RET2.
append idoc_data.
clear idoc_data.
idoc_data-segnam = 'E1EDL22'.
idoc_data-sdata = s_e1edl22.
append idoc_data.
clear idoc_data.
idoc_data-segnam = 'E1EDL21'.
idoc_data-sdata = s_e1edl21.
append idoc_data.
Any help will be well appreciated.
Thanks in advance.
Regards,
GiovanniHi,
following in debugging mode the abap code of the INCLUDE ZXTRKU02 where is defined the TABLES IDOC_DATA STRUCTURE EDIDD, I find that all field of the table IDOC_DATA are not set. More exactly my expectation is to find values for SEGNUM, HLEVEL, PSGNUM.
In a few words I need to execute an enhancement, via abap code, of the struscure of the idoc before sending it out since I have a requirement to test this enhancement in my XI environment, receiving as input this ideoc modified.
Then, I need to add a new segment and one child.
Any suggestion will be well appreciated.
Thanks in advance.
Regards,
Giovanni -
Error in the ABAP Code for Customer Exit Variable
Could you please update me what is the wrong with the below ABAP Code developed for Customer Exit Variable in BW
i created a Variable (ZVWKNO) of Customer Exit,Single Value ,Mandatory and Variable is ready for input
In CMOD i had written the below Code:
When 'ZVWKNO'.
DATA: WEEK(2) TYPE N,
WEEKNO(2) TYPE N.
IF i_step = 1.
l_st_date = SY-DATUM.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = l_st_date
IMPORTING
WEEK = l_fn_week.
CHECK sy-subrc = 0.
WEEK = l_fn_week+4(2).
If WEEK 0.
WEEKNO = WEEK - 1.
l_s_range-low = WEEKNO.
l_s_range-sign = k_sign_inclusive.
l_s_range-opt = k_option_equals.
APPEND l_s_range to e_t_range.
ENDIF.
ENDIF.
But when i execute the query the default value is not populated with Week-1 No in the variable screen
Please update me what went wrong
ThanksCase ZVWKNO. "write this with out comments
When '1'. "write the value that needs to equal with value in varaible ZVWKNO after when in sungle quotes
DATA: WEEK(2) TYPE N,
WEEKNO(2) TYPE N.
IF i_step = 1.
l_st_date = SY-DATUM.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = l_st_date
IMPORTING
WEEK = l_fn_week.
CHECK sy-subrc = 0.
WEEK = l_fn_week+4(2).
If WEEK 0. "check this Week Minimum is '01' and Maximum '52'
WEEKNO = WEEK - 1.
l_s_range-low = WEEKNO.
l_s_range-sign = k_sign_inclusive.
l_s_range-opt = k_option_equals.
APPEND l_s_range to e_t_range.
ENDIF.
ENDIF.
Prabhudas -
Calling a web service in an ABAP code
Hello Experts,
Is it possible to consume a web service in an ABAP code?
Note: I am using SAP R/3 4.7.
Thanks!
JeffreyDo you mean opening the web browser through our ABAP source code?
If yes, then please use the function module: "CALL_INTERNET_ADDRESS". This will do the job for you..
Reward points if I have helped you.
Regards -
Abap Code TO ENHANCE DATASOURCE with KEY FIELD OF SOURCE TABLE
Dear Friends, Please help me to resolve this important issue at my end.
<b>Requirement</b>: enhance the STRUCTURAL data source which is
based on the table VISTSU , now this table has a <b>key INTERNO</b> (Data Element : SECAINTRENO) which i want to enhance in datasource
SGONR = STRUCTURAL NUMBER present in extract structure of datasource
Solution: I am not able to see any records for zzinterno enhance field in datasource rsa3 (Extractor CHECKER). Can u help me correct the ABAP code or tell me the way to pull the records for ZZINTERNO from VISTSU table.
Thanks
Poonam Roy
ABAP Code
data: l_s_REIS_STRUCTURAL_ATTR like REIS_STRUCTURAL_ATTR.
case i_datasource.
WHEN '0STRUCTURAL_ATTR'.
loop at C_t_data into l_s_REIS_STRUCTURAL_ATTR.
l_tabix = sy-tabix.
clear I_VISTSU .
select single * from VISTSU into i_VISTSU where SG0NR = l_s_REIS_STRUCTURAL_ATTR-SGONR.
if sy-subrc = 0.
l_s_REIS_STRUCTURAL_ATTR-ZZINTRENO = I_VISTSU -INTRENO.
modify C_t_data from l_s_REIS_STRUCTURAL_ATTR index l_tabix.
endif.
endloop.
endcase.Try the below code.
data: l_s_REIS_STRUCTURAL_ATTR like REIS_STRUCTURAL_ATTR.
data: temp_interno like VISTSU -INTRENO.
data: h_tabix LIKE sy-tabix.
case i_datasource.
WHEN '0STRUCTURAL_ATTR'.
loop at C_t_data into l_s_REIS_STRUCTURAL_ATTR.
MOVE SY-TABIX TO H_TABIX.
clear temp_interno.
select single INTERNO from VISTSU into temp_interno where SG0NR = l_s_REIS_STRUCTURAL_ATTR-SGONR.
if sy-subrc = 0.
l_s_REIS_STRUCTURAL_ATTR-ZZINTRENO = temp_interno.
endif.
modify C_t_data from l_s_REIS_STRUCTURAL_ATTR index H_TABIX.
ENDLOOP.
ENDCASE.
Regards, Siva -
How to transfer data in change log table of dso to z-table using abap code
Hi can you please explain me how to transfer data in change log table of dso to z-table using abap code ,with out using Function module concept
PROGRAM NAME: ZBW_DELTA_TO_GSTAR **
report ZBW_DELTA_TO_GSTAR no standard page heading
line-size 120
line-count 75
message-id ZBW_MSG_CLS.
tables: ZGIV_DLTA_EBV_BB,
ZGIV_DLTA_EM2_BL,
ZGIV_DLTA_EM2_BK.
Selection Screen Definitions
SELECTION-SCREEN: BEGIN OF BLOCK INNER WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN: SKIP 1.
PARAMETERS: EBVBB RADIOBUTTON GROUP ROLL,
EM2BL RADIOBUTTON GROUP ROLL,
EM2BK RADIOBUTTON GROUP ROLL.
SELECTION-SCREEN: END OF BLOCK INNER.
Data: WS_UPDATE_FLAG Type C,
UCounter(9) Type N,
ICounter(9) Type N.
DATA: T_ZGIV_DLTA_EBV_BB Type Standard Table of ZGIV_DLTA_EBV_BB,
s_ZGIV_DLTA_EBV_BB LIKE line of T_ZGIV_DLTA_EBV_BB.
DATA: T_ZGIV_DLTA_EM2_BK Type Standard Table of ZGIV_DLTA_EM2_BK,
s_ZGIV_DLTA_EM2_BK LIKE line of T_ZGIV_DLTA_EM2_BK.
DATA: T_ZGIV_DLTA_EM2_BL Type Standard Table of ZGIV_DLTA_EM2_BL,
s_ZGIV_DLTA_EM2_BL LIKE line of T_ZGIV_DLTA_EM2_BL.
Standard Internal Tables - Describe usage.
data: begin of i_AEPSD_O0140 occurs 0.
include structure /BIC/AEPSD_O0140.
data: end of i_AEPSD_O0140.
data: begin of i_AEPSD_O0240 occurs 0.
include structure /BIC/AEPSD_O0240.
data: end of i_AEPSD_O0240.
data: begin of i_AEPSD_O0340 occurs 0.
include structure /BIC/AEPSD_O0340.
data: end of i_AEPSD_O0340.
data: begin of i_GIV_DLTA_EBV_BB occurs 0.
include structure ZGIV_DLTA_EBV_BB.
data: end of i_GIV_DLTA_EBV_BB.
data: begin of i_GIV_DLTA_EM2_BK occurs 0.
include structure ZGIV_DLTA_EM2_BK.
data: end of i_GIV_DLTA_EM2_BK.
data: begin of i_GIV_DLTA_EM2_BL occurs 0.
include structure ZGIV_DLTA_EM2_BL.
data: end of i_GIV_DLTA_EM2_BL.
Miscellaneous Program Variables and Constants.
TOP-OF-PAGE
top-of-page.
START-OF-SELECTION
start-of-selection.
Clear: i_GIV_DLTA_EBV_BB,
i_GIV_DLTA_EM2_BK,
i_GIV_DLTA_EM2_BL,
UCounter, ICounter.
IF EBVBB = 'X'.
PERFORM 100_EXTRACT_EBV_BB_DELTA_RECS.
ELSEIF EM2BK = 'X'.
PERFORM 100_EXTRACT_EM2_BK_DELTA_RECS.
ELSE.
PERFORM 100_EXTRACT_EM2_BL_DELTA_RECS.
ENDIF.
FORM 100_EXTRACT_EBV_BB_DELTA_RECS
FORM 100_EXTRACT_EBV_BB_DELTA_RECS.
Refresh: i_AEPSD_O0140,
i_GIV_DLTA_EBV_BB.
Clear: UCounter, ICounter, s_ZGIV_DLTA_EBV_BB .
Select * From /BIC/AEPSD_O0140
Into TABLE i_AEPSD_O0140.
IF SY-Subrc = 0.
LOOP AT i_AEPSD_O0140.
MOVE-CORRESPONDING i_AEPSD_O0140 TO s_ZGIV_DLTA_EBV_BB.
MOVE SY-DATUM to s_ZGIV_DLTA_EBV_BB-create_dt.
INSERT ZGIV_DLTA_EBV_BB FROM s_ZGIV_DLTA_EBV_BB.
IF SY-Subrc = 0.
ICounter = ICounter + 1.
ELSE.
UPDATE ZGIV_DLTA_EBV_BB FROM s_ZGIV_DLTA_EBV_BB.
IF SY-Subrc = 0.
UCounter = UCounter + 1.
ELSE.
Message E067 with SY-DATUM ' ' SY-UZEIT ' '.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. "100_EXTRACT_EBV_BB_DELTA_RECS
FORM 100_EXTRACT_EM2_BK_DELTA_RECS
FORM 100_EXTRACT_EM2_BK_DELTA_RECS.
Refresh: i_AEPSD_O0240,
i_GIV_DLTA_EM2_BK.
Clear: UCounter, ICounter, s_ZGIV_DLTA_EM2_BK .
Select * From /BIC/AEPSD_O0240
Into TABLE i_AEPSD_O0240.
IF SY-Subrc = 0.
LOOP AT i_AEPSD_O0240.
MOVE-CORRESPONDING i_AEPSD_O0240 TO s_ZGIV_DLTA_EM2_BK.
MOVE SY-DATUM to s_ZGIV_DLTA_EM2_BK-create_dt.
INSERT ZGIV_DLTA_EM2_BK FROM s_ZGIV_DLTA_EM2_BK.
IF SY-Subrc = 0.
ICounter = ICounter + 1.
ELSE.
UPDATE ZGIV_DLTA_EM2_BK FROM s_ZGIV_DLTA_EM2_BK.
IF SY-Subrc = 0.
UCounter = UCounter + 1.
ELSE.
Message E067 with SY-DATUM ' ' SY-UZEIT ' '.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. "100_EXTRACT_EM2_BK_DELTA_RECS
FORM 100_EXTRACT_EM2_BL_DELTA_RECS
FORM 100_EXTRACT_EM2_BL_DELTA_RECS.
Refresh: i_AEPSD_O0340,
i_GIV_DLTA_EM2_BL.
Clear: UCounter, ICounter, s_ZGIV_DLTA_EM2_BL .
Select * From /BIC/AEPSD_O0340
Into TABLE i_AEPSD_O0340.
IF SY-Subrc = 0.
LOOP AT i_AEPSD_O0340.
MOVE-CORRESPONDING i_AEPSD_O0340 TO s_ZGIV_DLTA_EM2_BL.
MOVE SY-DATUM to s_ZGIV_DLTA_EM2_BL-create_dt.
INSERT ZGIV_DLTA_EM2_BL FROM s_ZGIV_DLTA_EM2_BL.
IF SY-Subrc = 0.
ICounter = ICounter + 1.
ELSE.
UPDATE ZGIV_DLTA_EM2_BL FROM s_ZGIV_DLTA_EM2_BL.
IF SY-Subrc = 0.
UCounter = UCounter + 1.
ELSE.
Message E067 with SY-DATUM ' ' SY-UZEIT ' '.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. "100_EXTRACT_EM2_BL_DELTA_RECS
END-OF-SELECTION
end-of-selection.
perform D1000_REPORT_DATA.
D1000_REPORT_DATA
form D1000_REPORT_DATA.
*Display the title of the program
write: /25 SY-TITLE.
skip.
Diaplay the details of the user and time
write: /1 'Executed by', 15 SY-UNAME, 30 'Date',
38 SY-DATUM, 53 'Time', 60 SY-UZEIT.
skip 2.
write: / 'Delta Records have been extracted ',
/ 'Updates : ', UCounter,
/ 'Inserts : ', ICounter.
skip.
skip 3.
write: /20 'End of the report'.
endform. "D1000_REPORT_DATA
chgeck it out this also may hep you
Maybe you are looking for
-
Cell definition choice in Query Designer is inactive
In the Query Designer the choice "Define cells" is inactive, or grayed out. Why is this? Is there a global setting or does it have something to do with the query itself?
-
Open hidden macro file "personal.xls" with ActiveX in Excel?
Aarrghh... I've almost got this sub-vi working. It runs a macro on an Excel file to format the cells with borders, bold fonts, etc. then closes it and saves as a spec'd filename. It works if before I run it, I open Excel... personal.xls, the hidden f
-
In Pages when I click the 'Sections' button then click on the 1st page I get a page that is titled "Lorem ipsum dolor sit amet"! Where did it come from and how do I get rid of it? I have tried deleting and "dont save" but it comes back. It is a fu
-
Can't update AE CC 2014.1.1 (13.1.1)
Hello, I have a trouble by updating AE CC 2014.1.1 (13.1.1). I have a Windows 7 64bit and I am a memeber of Creative Cloud. I tried to install the update by the Creative Cloud desktop application and also by AE menu. i also tried to unistall AE and i
-
How do I turn off mail notifications?
I already went to System Preferences > Notifications and set Mail Alert Style to "none" and also unchecking notification center, badge app icon and sound options. Despite taking these steps, the mail icon in my dock displays a "new email" light and d