Application Development 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: 

advise on which method is more performance

Former Member
0 Kudos
204

I have to initialise the structure BBSEG with / value

please advise of these 2 method which is more performance

method 1 -->(Using the FM NAMETAB)

REFRESH nametab.

CALL FUNCTION 'NAMETAB_GET'

EXPORTING

langu = sy-langu

tabname = tabname

TABLES

nametab = nametab

EXCEPTIONS

no_texts_found = 1.

IF sy-subrc NE 0.

MESSAGE e000 WITH 'DDIC Structure ' tabname ' not found'.

ENDIF.

LOOP AT nametab.

CLEAR char.

CONCATENATE 'I_' nametab-tabname '-' nametab-fieldname INTO char.

ASSIGN (char) TO <f1>.

<f1> = i_nodata.

ENDLOOP.

-


Methos 2 -->

data : wa_bbseg type bbseg.

field-symbols : <fs> type any.

do.

assign component sy-index of structure wa_bbseg to <fs>.

if sy-subrc = 0.

<fs> = '/'.

else.

exit.

endif.

enddo.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
167

Hi,

Second one is better.......Field Symbols are always used for the Better performance as they eliminates the need of any workarea/Headerline/Strucutre for any Value transfer, and hence less memory and processing is required.

15 REPLIES 15

JozsefSzikszai
Active Contributor
0 Kudos
167

2nd one is definetly faster, from programing technical point of view also better.

Former Member
0 Kudos
167

Hi,

Performance wise second method id faster as it takes less execution time and run time analysis is efficient in second method.

Regards,

Rahul

Former Member
0 Kudos
168

Hi,

Second one is better.......Field Symbols are always used for the Better performance as they eliminates the need of any workarea/Headerline/Strucutre for any Value transfer, and hence less memory and processing is required.

0 Kudos
167

Methos 2 -->

data : wa_bbseg type bbseg.

field-symbols : <fs> type any.

do.

assign component sy-index of structure wa_bbseg to <fs>.

if sy-subrc = 0.

<fs> = '/'.

else.

exit.

endif.

enddo.

Concerning the second method i the <fs> type any

0 Kudos
167

>

Concerning the second method i the <fs> type any

you should not have any concern about it...

0 Kudos
167

Sorry i didn't complete the question i wanted to ask what if i want to put a TYPE with the FS

<FS> type BBSEG

a dump occur in the line code assign

0 Kudos
167

Hi,

You have to change code as:

tables:
bbseg.

field-symbols:
<FS> type BBSEG.

Assign bbseg to <FS>.

Thanks & Regards,

Navneeth K.

0 Kudos
167

<fs> TYPE bbseg => here the field symbols will be like a work area

<fs> TYPE ANY => here the field symbol can be anything

in your example you assign the fields of the work area (one by one) to the field symbols, so the <fs> TYPE bbseg will result in a dump.

0 Kudos
167

mention tables statement inorder to avoid dump or else create a workarea:

data:
wa type bbseg.

field-symbols:
<FS> type BBSEG.
 
Assign wa to <FS>.

0 Kudos
167

>

> Hi,

>

> You have to change code as:

>

>

tables:
> bbseg.
> 
> field-symbols:
> <FS> type BBSEG.
> 
> Assign bbseg to <FS>.

>

> Thanks & Regards,

> Navneeth K.

and how will you put a slash into each field (the original requirement here) ?

0 Kudos
167

With the <FS> type any it work fine

it's only with the <FS> type BBSEG that it dump. i am not too familiar with field symbol could you please explain me the reason

0 Kudos
167

I already gave explanation in my previous reply, to add some more: in the DO ... ENDDO you assign each single field to the field symbol (in "normal" ABAP would look like: field1 = variable). if the field symbol is TYPE bbseg, that would be like field1 = work area ==> error!

0 Kudos
167

>

> With the <FS> type any it work fine

>

> it's only with the <FS> type BBSEG that it dump. i am not too familiar with field symbol could you please explain me the reason

Why if it works fine with TYPE ANY would you want to try and type it on something else? Especially to type it on BBSEG which is totally wrong for what it is being used for (as explained above). Just making extra work for yourself.

There is nothing wrong with using TYPE ANY; it facilitates the main advantage of using field symbols ie that you can use them to point to any field you want whatever the type.

matt
Active Contributor
0 Kudos
167

>

>

> There is nothing wrong with using TYPE ANY; it facilitates the main advantage of using field symbols ie that you can use them to point to any field you want whatever the type.

That advantage is the main reason why you should not use type any. See my blog about[ type safety.|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/11938] [original link is broken] [original link is broken] [original link is broken];

matt

Former Member
0 Kudos
167

Academic discussion. Use standard SAP functionality to do this:

PERFORM INIT_BBSEG(RFBIBLI0) USING BBSEG.

Rob