‎2009 May 08 6:35 AM
hii all,
I am updating parts master using BAPI in which there are 150 fields for me to update..
the notation in the excel are as follows
if field is not to be updated we give the cell value as '@@@'
if field value is blank we give it as space(normal way)
if field need to be updated with a value we give that value, in appropriate cells of excel sheet.
i got these values into internal table but the problem is, i have to check for fields that are not be updated so that in the BAPIX structure i have leave these fields blank..
I can loop at internal table and manually check like
LOOP AT ITAB INTO WA.
IF WA-F1 NE '@@@'.
.....
ENDIF.
IF WA-F2 NE '@@@'.
...
ENDIF.
....upto 150 fields
ENDLOOP.
can i reduce this redundancy by accessing the fields of work area dynamically,probably by field symbols.
with reagrds,
sandeep akella.
‎2009 May 08 7:40 AM
hello all,
thank you all, now i am able to access the fields of work area dynamically..but i want to get the name of the component so that i can update the same field in BAPIX structure.
with regards,
sandeep akella.
‎2009 May 08 6:45 AM
Hi Sandeep,
Why can you merge all the fields under once condition like,
If wa-f1 ne '@@@' and wa-f2 ne '@@@' and wa-f3 ne '@@@' and .... wa-f150 ne '@@@'.
-
endif.
Thanks & regards,
Dileep .C
‎2009 May 08 6:46 AM
Hi..
checkout following sample code.
FORM GET_FIELD
IF <FS1> IS ASSIGNED.
UNASSIGN <FS1>.
ENDIF.
IF <FS2> IS ASSIGNED.
UNASSIGN <FS2>.
ENDIF.
CLEAR: G_STRING,G_CHARATINN.
CONCATENATE 'WA_ITAB_OUTPUT' '-' WA_CONF_SRC-IT_FNAME INTO G_STRING.
G_CHARATINN = WA_CONF_SRC-CHAR_ATNAM.
ASSIGN (G_STRING) TO <FS2>.
IF SY-SUBRC = 4.
IF <FS2> IS ASSIGNED.
UNASSIGN <FS2>.
ENDIF.
ENDIF.
ENDFORM.
**********************************************************************************
LOOP AT IT_CONF_SRC INTO WA_CONF_SRC.
PERFORM GET_FIELD.
IF <FS1> IS ASSIGNED.
PERFORM BDC_FIELD USING 'RCTMS-MNAME(01)' <FS1>.
UNASSIGN <FS1>.
ENDIF.
IF <FS2> IS ASSIGNED.
PERFORM BDC_FIELD USING 'RCTMS-MWERT(01)' <FS2>.
UNASSIGN <FS2>.
ENDIF.
ENDLOOP.
here 'WA_ITAB_OUTPUT' is ur workarea for that and it_conf table contain field list ( 150 fields ).
hOPE THIS HELPFUL TO YOU...
Regards,
Chintan.
‎2009 May 08 6:49 AM
hi sandep
u can do by field symbols so that u do not need to write 150 if statements
simple code is as folows
field-symbol <fs> type any.
LOOP AT itab into wa.
DO.
UNASSIGN <fs>.
ASSIGN COMPONENT sy-index OF STRUCTURE wa TO
<fs>.
IF sy-subrc NE 0.
EXIT.
ENDIF.
IF <fs> eq '@@'.
<fs> = ''.
ENDIF.
ENDDO.
endloop.
using this u can do , u read fields of the work area and if they coantian '@@' value u can blank them else keep them same
hope this resolvs ur problem
afzal
‎2009 May 08 7:03 AM
Hi,
To reduce the redundancy... use field symbols.... you can just copy and paste the code given below.... which is easily understandable...
we assign components of the work area one by one to field symbol in do loop and check with the value of that field symbol if it is @@@ or not...
FIELD-SYMBOLS : <fs_wa> TYPE ANY.
DATA w_type TYPE string.
DATA w_comp TYPE i.
DESCRIBE FIELD wa TYPE w_type COMPONENTS w_comp.
LOOP AT itab INTO wa.
DO w_comp TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE wa TO <fs_wa>.
IF <fs_wa> NE '@@@'.
....
ENDIF.
ENDDO.
UNASSIGN <fs_wa>.
ENDLOOP.Regards,
Siddarth
‎2009 May 08 7:40 AM
hello all,
thank you all, now i am able to access the fields of work area dynamically..but i want to get the name of the component so that i can update the same field in BAPIX structure.
with regards,
sandeep akella.
‎2009 May 08 8:02 AM
hi sandeep
u cant get the name of the component instead u can use little trick
i mean as u are pointing to the component the same way u can point to the component of bapi with field symbol
simple code
field symbols fs1 , fs2.
do .
ASSIGN COMPONENT sy-index OF STRUCTURE wa to <fs1>
.
IF sy-subrc NE 0.
EXIT.
ENDIF.
if <fs1> ne '@@'.
assign component sy-index of bapi to <fs2>
<fs2> = <fs1>.
else.
assign component sy-index of bapi to <fs2>
<fs2> = ' '.
endif.
ENDDO.
so ti will be one to one poitning form waork area to bapi
regards
azfal