2009 Aug 21 10:07 AM
Hi all gurus,
I'm rebuilding a report that performs a lot of checks by comparing fields of two different structures.
Basically, the check has a structure that is repeated over and over in many check: it looks like this:
IF srm_items-{field1} NE r3_services-{field2}.
t_temp-prezzi_errati = icon_red_light.
t_temp-error_code = '{errorcode}'.
IF counter_s = 0.
PERFORM add_son_in_t_temp USING srm_items e_backend w_obj-posting_date w_obj-changed_at.
ELSE.
PERFORM add_additional_error_temp USING srm_items 0.
ENDIF.
counter_s = counter_s + 1.
fl_errore_s = 'X'.I was thinking to create a form, say 'check_son', that takes as USING parameter , and . My doubt is about types ad casts; in a check, could be a text string, in another a number, in another again a guid, and so on. Always simple field (no structures or complex field by now), but for what that concerns my FORM:
FORM check_son USING compare1
compare2
errorcode.
how should I declare the form in order to have the check working? I mean, I'd like that compare1 and compare2 get the same TYPE of the parameter I pass.. Is there a way? Or implicitly the params are converted into text (this should not work for me)?
Thanks in advance
2009 Aug 21 10:18 AM
Hi Matteo,
If the parameters are not types then a cast may occur in the form itself.
It should be OK, but it depends on what you manage in the form...
Hope that helps.
Laurent
2009 Aug 21 10:18 AM
Hi Matteo,
If the parameters are not types then a cast may occur in the form itself.
It should be OK, but it depends on what you manage in the form...
Hope that helps.
Laurent
2009 Aug 21 10:27 AM
Hi Laurent,
if I leave the params without types, the default is that they interpreted as text.
The problem is that I will compare fields that are typized differently, and I'm scared about the "implicit" conversion in text of the field value.
Suppose I have to make a comparizon between two numeric field:
srm_item-number_int , which has value 000000001
and
foo_item-numero, which has value 01.
If the comparison is made between numbers, everything's ok. If I pass these two params to the form declared as above, I think it's a ko...
I hope the situation it's a bit more clear now... Basically, I'd like to know if there's a way to pass a non typized parameter to a form and obtain in the form itself the correct typization.
2009 Aug 21 6:39 PM
Two solutions:
- replace the form by a macro
- implement a dynamic data declaration
2009 Aug 22 11:33 AM
Hi Dieu,
can you be more specific and address me to some example/documentation? I don't know macros and I don't know how to implement dynamic declaration in abap. Thank you.
2009 Aug 22 11:54 AM
>
> I don't know macros
Hi, Matteo
Test the following Sample Code it will help you to understand the working of Macros.
DEFINE check_son.
if &1 NE &2. " If Field1 Not Equal Field2
&3 = 'NE'. " In This Variable it will Return Error Code NE for Not Equal and EQ for Equal
else.
&3 = 'EQ'.
endif.
END-OF-DEFINITION.
DEFINE write_message.
if &1 = 'EQ'.
write: 'Two Numbers are Equal', /.
else.
write: 'Two Numbers are Not Equal', /.
endif.
END-OF-DEFINITION.
DATA: f1 TYPE i,
f2 TYPE i,
error_code(2).
f1 = 10. f2 = 15.
check_son f1 f2 error_code.
write_message error_code.
f1 = 10. f2 = 10.
check_son f1 f2 error_code.
write_message error_code.Please Reply if any Confusion,
Best Regards,
Faisal
2009 Aug 22 11:57 AM
Hi,
If there is some process in a program which is called frequently then we use macros. We can create a macro using the DEFINE u2026 END-OF-DEFINITION statement. Unlike function modules, macros are not available throughout the system and are available only in that particular program.
Example:
data : result type I.
define macro.
result = 1 + 2.
write result.
end-of-definition.
macro.this macro can be called where ever necessary.
Thanks,
Sri.
2009 Aug 22 1:40 PM
In addition: in a macro you can use specific statements, such as "AT <fielld>... ENDAT", that you cannot use in a form.
2009 Sep 15 11:49 AM