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

CLEAR...WITH statement in structure

Former Member
0 Likes
1,418

Hi all,

I have a structure called MBEW, for which I have created a work area called WA_MBEW. This structure has numeric as well as character type fields. Now I want to initialise all <b>character type</b> fields with '/'. So I have a variable called NODATA TYPE c VALUE '/'.

Is there any way I can initialise only char fields with NODATA?

I tried CLEAR WA_MBEW WITH NODATA, but this doesnt work bcoz of the numeric fields. Plz help

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,389

Welcome to SDN!!!

CLEAR wa_mbew.
wa_mbew = '/'.

Reward if this helps. else revrt back with queries.

15 REPLIES 15
Read only

Former Member
0 Likes
1,390

Welcome to SDN!!!

CLEAR wa_mbew.
wa_mbew = '/'.

Reward if this helps. else revrt back with queries.

Read only

0 Likes
1,389

Thx so much Judith... mann, this forum's fast

Read only

0 Likes
1,389

Hi,

I tried to write out a few CHAR fields, but they're still blank, not '/'... any suggestions?

Read only

0 Likes
1,389

Can u give me the part of the code with declarations.

<b>DATA: wa(10) TYPE c value 'Test'.

clear wa.

wa = '/'.

Write:/ wa.</b>

This works fine for me.

Read only

0 Likes
1,389
can u post ur code?

or else, assign each char field with a /

wa_mbew-char1 = nodata.
wa_mbew-char2 = nodata.
wa_mbew-char3 = nodata.
wa_mbew-char4 = nodata.
Read only

0 Likes
1,389

DATA : WA_MBEW LIKE MBEW.

*MBEW is a structure with abt 100 fields, with types char, numc, curr etc etc

DATA : NODATA TYPE C VALUE '/' "Defined in an include

IF WA_MBEW IS INITIAL.

CLEAR WA_MBEW WITH NODATA. "Throws error

ENDIF.

Read only

0 Likes
1,389

Hi,

Try this its workign fine

DATA: wa LIKE MBEW.
if wa is initial.
clear wa WITH '/'.
endif.
Write:/ wa.

Reward if this helps.

Read only

0 Likes
1,389

Judith, ur code is throwin this syntax error:

"WA" must be a character type data object (C,N,D,T,String).

I'm guessing this is a Unicode compatibility error, right?

Is there any function module which will return the name and type of fields in a DDIC structure? That way, I might be able to use an internal table and then loop around it, initialising only for CHAR type fields.

Read only

0 Likes
1,389

I dont know y this problem, I am workign in 4.6c and its running without any syntax error.

Read only

0 Likes
1,389

Try using the FM: GET_COMPONENT_LIST to get the types of the internal table fields.

Regards,

Ravi

Read only

0 Likes
1,389

just chk whether u had selected the checkbox "Unicode checks active" when u created ur test report

Read only

Former Member
0 Likes
1,389

<b>DATA: TEXT(1) VALUE '/',

BEGIN OF PLAYER,

NAME(10) VALUE 'John',

TEL(8) TYPE N VALUE '08154711',

MONEY TYPE P VALUE 30000,

END OF PLAYER.

CLEAR: NUMBER, PLAYER-name with text.

.</b>

or

<b>ABOVE Code is BEST one .</b>

Regards

Prabhu

Read only

Former Member
0 Likes
1,389

Try this..

CLEAR  WA_MBEW.

WA_MBEW = NODATA

Read only

Former Member
0 Likes
1,389

Answer not working

Read only

0 Likes
1,389

Hi,

yesit will post error because your structure WA_MBEW contains not only character field but also different data types.

so only option is u have to explicitly assign the character fields to nodata.

DATA : WA_MBEW LIKE MBEW.

*MBEW is a structure with abt 100 fields, with types char, numc, curr

*etc etc

DATA : NODATA TYPE C VALUE '/'. "Defined in an include

IF WA_MBEW IS INITIAL.

WA_MBEW-VPRSV = nodata.

ENDIF.

in the same way assign all char fieds to nodata.

Regards,

Sruthi