Skip to Content
0

Code Template ABAP in Eclipse

Feb 14, 2017 at 08:56 AM

621

avatar image

As we all know iIn SAP GUI it is possible to use 'Pattern' function to import (for example) a function module with it's entire interface (import, export, tables, changing, exceptions). This is also possible in AiE. However, in SAP GUI, via (menu) settings ABAP Editor->Pattern you can also set the following option: 'Name of actual parameter same as Formal Parameter'. Beside the named parameters also the data declaration is done.

*DATA IF_SOFORTAUFTRAG TYPE XFELD.
*DATA IF_GET_HUS       TYPE XFELD.
*DATA IF_DEQUEUE       TYPE XFELD.
*DATA IT_VENUM         TYPE HUM_VENUM_T.
*DATA ET_VEKP          TYPE VSEP_T_VEKP.
*DATA ET_VEPO          TYPE VSEP_T_VEPO.

CALL FUNCTION 'HU_PACKING_REFRESH'
* EXPORTING
*   IF_SOFORTAUFTRAG       = ' '
*   IF_GET_HUS             = IF_GET_HUS
*   IF_DEQUEUE             = IF_DEQUEUE
*   IT_VENUM               = IT_VENUM
* IMPORTING
*   ET_VEKP                = ET_VEKP
*   ET_VEPO                = ET_VEPO.

Can I also achieve the same in ABAP in Eclipse? I know about templates and code suggestions, but that won't give me the data declaration part.

Kind regards,

Micky

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Suhas Saha
Feb 14, 2017 at 12:44 PM
2

Hi Micky,

Nice to see you after a long time :)

Tbh, i had the same problem like you when i started working with Eclipse. But then i realised the power of "Quick Fixes".

Base Template you get by using code completion Ctrl+Space

Comment out the parameters you would be needing & hit Ctrl+1 (QuickFix).

N.B.: QuickFixes somehow don't like procedural programming :)

The needed (local)variables will be automatically defined by ADT.

IMHO the ADT feature is more comfortable than the GUI feature.

BR,

Suhas


Show 8 Share
10 |10000 characters needed characters left characters exceeded

You still have to type the variable names against the IMPORT/ EXPORT parameters correct? Here is what I get when do the quick complete

CALL FUNCTION 'HU_PACKING_REFRESH'
*  EXPORTING
*    if_sofortauftrag = SPACE
*    if_get_hus       = 
*    if_dequeue       =     " Checkbox
*    it_venum         =     " Table Type for Internal Handling Unit Numbers
*  IMPORTING
*    et_vekp          =     " HU Header Table
*    et_vepo          = 
.

Is there a preference to turn the auto insertion of variables?

@Micky, even if there isn't an option to turn on the automatic variables, the rest of the QuickFixes and just the way that auto-complete works more than make up for it. I just tried to do something with Java GUI on MacOS (old, old editor) and I was lost for a few minutes!

1

You still have to type the variable names against the IMPORT/ EXPORT parameters correct?

Sorry for missing the part where one has to declare the variables manually & then hit the QuickFix(QF) :-(

In the GUI editor all the parameters will be inserted automatically, even if you don't need them. Also the names of these variables are same as the formal parameters. Most of the time you end up renaming them to something more meaningful and/or deleting them when you don't need them. Doesn't save your time anyway.

IMHO in ADT the approach is more pragmatic! Define the variables you'll need & let the QF create them for you.

1

The code completion of ADT provides

CALL FUNCTION 'HU_PACKING_REFRESH'
*  EXPORTING
*    if_sofortauftrag = SPACE
*    if_get_hus       = 

or

CALL FUNCTION 'HU_PACKING_REFRESH'
*  EXPORTING
*    if_sofortauftrag = if_sofortauftrag
*    if_get_hus       = if_get_hus

depending on your SE80 settings in that system.

It would be better if this setting was also available in the ADT properties but currently it is not...

Best regards,
Armin

pattern-params.jpg (90.4 kB)
2

Hi Armin,

I tend to agree with you (should be available in ADT as well), but the Quick Fix options Suhas mentions should be good enough (at least for me).

BR. Micky.

0

Hi Raghu,

thanks for the reply (and also sorry for the late reply due to missed notifications).

I also do not get the options Suhas gets when trying to do a quick fix. Indeed, often the QF makes up for quite some 'issues' but I'm not sure it does in this case. Would be nice if the QF would work the same for me as it does for Suhas. Than it would make up for it.

BR. Micky.

0

Hi Suhas,

indeed, it's been a while (especially when it comes to answering questions).

Sorry for the late reply. I somehow missed the notification.

When I look at your screen shot when hitting CTRL+1 I see a lot of possible 'actions' among others the possibility to select 'declare 4 local variables'. However, when I try to do a Quick Fix (a feature I was aware of) I only get the following options:

Which version ADT are you on?

If the QF would provide the options you are getting, it would be (more or less) what I would be looking for.

Is it more comfortable than the SAP GUI...? Probably if it declares them locally with the proper naming convention (lv_, lt_, ls_, etc.).

BR. Micky.

quickfixscn.jpg (26.5 kB)
0

Hi Micky,

When I look at your screen shot when hitting CTRL+1 I see a lot of possible 'actions' among others the possibility to select 'declare 4 local variables'.

That's because i called the FM inside a method. As i have alrerady mentioned in the previous post, QFs don't like procedural programming. I think you are trying to apply the QF in a procedural code & therefore don't get the full range of QF options.

Probably if it declares them locally with the proper naming convention (lv_, lt_, ls_, etc.).

No, it doesn't. You'll have to define the actual parameters manually in the call to the FM & then hit the QF. ADT will then declare the variables for you.

BR,

Suhas

1

Hi Suhas,

now I know what you mean by 'QF doesn't like procedural programming'. You are absolutely correct, the QF now indeed gives me the options to declare all variables.

Thanks. will definitely be very helpful in my day-to-day work!

KR. Micky.

0
Rob Dielemans Feb 15, 2017 at 11:45 AM
1

Hey Mickey,

Long time no see :)

I didn't even know of this option in the ABAP editor, even though I unearthed how to make dynamic patterns a loooong time ago.

You could send an email to the editor of the ABAP plug in requesting this functionality in a future release.

Cheers, Rob Dielemans

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Rob,

indeed, long time no see.

As you can see in above replies, the quick fix should be the 'fix' I'm looking for. But for now I will have to declare them myself as long as I only get the options I mentioned above. So hopefully it's just a matter of the ADT version I'm currently working on (even though I thought I have the latest version downloaded not so long ago).

BR. Micky.

P.S. Good to see that you are still very active (even) on (the new) SCN.

0