Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BADI problem

Former Member
0 Likes
716

Hi,

I am writing a BADI.somebody coded already...I am modifying the code.

I have created one ZTable, that table contains 2 fields one is Date and another one is Program name.

my problem is, the date (20050510) in the following code is hard coded...now i want to replace the 20050510 with Ztable date field.

IF <ACCIT_EX>-ACCIT-BUDAT > '20050510' OR

<ACCIT_EX>-ACCIT-AWTYP = 'BEBD' OR

<ACCIT_EX>-ACCIT-AWTYP = 'ACE'.

EXIT.

ENDIF.

how can we do this?

where should i declare the table name and field name(Date) in BADI...

how can i call?

Thanks in advance,

Yad.

1 ACCEPTED SOLUTION
Read only

ssimsekler
Product and Topic Expert
Product and Topic Expert
0 Likes
546

Hi Yad

So your Z table seems to have some customization value. Why not defining it in the BAdI code?

<b>DATA lv_date TYPE sydatum .

SELECT SINGLE date FROM ztable
       INTO lv_date
       WHERE <i><your_condition></i> .

IF sy-subrc NE 0 .
*--Setting lv_date if not found in Ztable
ENDIF .</b>

IF <ACCIT_EX>-ACCIT-BUDAT > <b>lv_date</b> OR 
<ACCIT_EX>-ACCIT-AWTYP = 'BEBD' OR 
<ACCIT_EX>-ACCIT-AWTYP = 'ACE'. 
EXIT. 
ENDIF.

However, instead of program name, I would use transaction code to choose dates.

e.g.

SELECT SINGLE date from ztable
       INTO lv_date
       WHERE <b>tcode = sy-tcode</b> .

Regards

*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

3 REPLIES 3
Read only

ssimsekler
Product and Topic Expert
Product and Topic Expert
0 Likes
547

Hi Yad

So your Z table seems to have some customization value. Why not defining it in the BAdI code?

<b>DATA lv_date TYPE sydatum .

SELECT SINGLE date FROM ztable
       INTO lv_date
       WHERE <i><your_condition></i> .

IF sy-subrc NE 0 .
*--Setting lv_date if not found in Ztable
ENDIF .</b>

IF <ACCIT_EX>-ACCIT-BUDAT > <b>lv_date</b> OR 
<ACCIT_EX>-ACCIT-AWTYP = 'BEBD' OR 
<ACCIT_EX>-ACCIT-AWTYP = 'ACE'. 
EXIT. 
ENDIF.

However, instead of program name, I would use transaction code to choose dates.

e.g.

SELECT SINGLE date from ztable
       INTO lv_date
       WHERE <b>tcode = sy-tcode</b> .

Regards

*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

Read only

0 Likes
546

hi Serdar,

Thanks for ur reply.i have one doubt.In report's we will declare tables like this

tables: mara, marm, ztable.

but in BADI where should i declare like that? In class or some where?

I didn't worked till now in BADI.

thanks,

Yad.

Read only

ssimsekler
Product and Topic Expert
Product and Topic Expert
0 Likes
546

Hi Yad

Think BAdI as a function module for now. With TABLES statement, we declare not tables but row structure with the same row type of a table. This is something from the older versions of ABAP. The code I have written will do what you want. There you do not need to use a TABLES statement.

By the way, since you are new to SDN, I'd like to tell that if you find an answer helpful, you can reward points to it using the scala on the left of each specific post and for the post which solves your question click the appropriate option saying it solved your problem. If you yourself solve your problem, then click the relevant radiobutton at the left of your original post. This way, you will save valuable times of SDNers.

Regards

*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>