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

Problem in field leght checking..

Former Member
0 Likes
1,175

HI all,

DATA: BEGIN OF I_MARD OCCURS 0,

MATNR LIKE MARD-MATNR, "18

WERKS LIKE MARD-WERKS, "4

LGORT LIKE MARD-LGORT, "4

LABST LIKE MARD-LABST, "18

END OF I_MARD.

SELECT MATNR

WERKS

LGORT

LABST

INTO TABLE I_MARD

FROM MARD.

LOOP AT I_MARD.

WRITE: / I_MARD(22).

IF NOT I_MARD+22 IS INITIAL.

WRITE:/ I_MARD+22.

ELSE.

WRITE:/20 '-'.

ENDIF.

ENDLOOP.

Here i am having total field legth is 42. In that i an writing first 22 char. after that i checking about the remaing data.

But it is not allowing me to activate..please check it & let know your inputs..

ok now ur req is clear:

here is the modified code>>>

REPORT  zj_test.
DATA: BEGIN OF i_mard OCCURS 0,
matnr LIKE mard-matnr, "18
werks LIKE mard-werks, "4
lgort LIKE mard-lgort, "4
labst LIKE mard-labst, "18
END OF i_mard.

SELECT matnr
werks
lgort
labst
INTO TABLE i_mard
FROM mard.

LOOP AT i_mard.
  WRITE: / i_mard(22).
  IF NOT i_mard+0(22) IS INITIAL.
    WRITE:/10 i_mard-lgort, i_mard-labst.
  ELSE.
    WRITE:/20 '-'.
  ENDIF.
ENDLOOP.

9 REPLIES 9
Read only

former_member156446
Active Contributor
0 Likes
1,149

Hi

you were missing +0(22)

DATA: BEGIN OF i_mard OCCURS 0,
matnr LIKE mard-matnr, "18
werks LIKE mard-werks, "4
lgort LIKE mard-lgort, "4
labst LIKE mard-labst, "18
END OF i_mard.

SELECT matnr
werks
lgort
labst
INTO TABLE i_mard
FROM mard.

LOOP AT i_mard.
  WRITE: / i_mard(22).
  IF NOT i_mard+0(22) IS INITIAL.
    WRITE:/ i_mard+0(22).
  ELSE.
    WRITE:/20 '-'.
  ENDIF.
ENDLOOP.

Read only

0 Likes
1,149

HI J@y,

As per your suggestion I have modified the code and activated. But it is not displaying full data.

Here in I_mard table I am having the below data.

Row MATNR WERKS LGORT LABST

1 20000901 1039 09B1 10.23

2 20000902 1039 911 10.25

3 20000902 1039 912 10.56

4 20000902 1039 913 10.56

5 20000902 1039 919 10.56

6 20000902 1039 921 10.56

7 20000902 1039 922 10.56

But in the output iam getting the only 2 fields of data so what about remaining LGORT and LABST.

20000901 1039

20000901 1039

20000902 1039

20000902 1039

20000902 1039

20000902 1039

20000902 1039

Here in my condition is;

1st MATNR and WERKS will be written and by using this statement: WRITE: / I_MARD(22).

and then by using the other condition iam checking the data of remaing 2 fileds.

IF NOT I_MARD+0(22) IS INITIAL.

WRITE:/ I_MARD+0(22).

ELSE.

WRITE:/20 '-'.

ENDIF.

if we dont have the date for next 3 fields '-' will be displayed.

Please check it. this is important for me..

Edited by: Mahaboob on Nov 13, 2008 10:10 PM

Read only

0 Likes
1,149

ok now ur req is clear:

here is the modified code>>>

REPORT  zj_test.
DATA: BEGIN OF i_mard OCCURS 0,
matnr LIKE mard-matnr, "18
werks LIKE mard-werks, "4
lgort LIKE mard-lgort, "4
labst LIKE mard-labst, "18
END OF i_mard.

SELECT matnr
werks
lgort
labst
INTO TABLE i_mard
FROM mard.

LOOP AT i_mard.
  WRITE: / i_mard(22).
  IF NOT i_mard+0(22) IS INITIAL.
    WRITE:/10 i_mard-lgort, i_mard-labst.
  ELSE.
    WRITE:/20 '-'.
  ENDIF.
ENDLOOP.

Read only

0 Likes
1,149

HI J@y,

Asper your logic agian your checking 1st 2 fields. bUt my requirement is i need to check 3rd and 4th field of data. if no data in 3rd and 4th field i need to pass '-'

LOOP AT i_mard.

WRITE: / i_mard(22).

IF NOT i_mard+0(22) IS INITIAL.

WRITE:/10 i_mard-lgort, i_mard-labst.

ELSE.

WRITE:/20 '-'.

ENDIF.

ENDLOOP.

please check it once..

Read only

0 Likes
1,149

oh man!!!!

LOOP AT i_mard.
  WRITE: / i_mard(22).
  IF NOT i_mard-lgort IS INITIAL AND i_mard-labst IS INITIAL.  " check if you need *and* or *OR*
    WRITE:/10 i_mard-lgort, i_mard-labst.
  ELSE.
    WRITE:/20 '-'.
  ENDIF.
ENDLOOP.

Read only

0 Likes
1,149

Thanks to all

Read only

Former Member
0 Likes
1,149

assuming you want to write the last 20 bytes use


IF NOT I_MARD+22(20) IS INITIAL.
WRITE:/ I_MARD+22(20).

Read only

0 Likes
1,149

HI MxG,

getting this error.

The sum of the offset and length (=44) exceeds the length of the start

(=26) of the structure. - not allowed in Unicode programs. -

Program Y_TEST1234

The sum of the offset and length (=44) exceeds the length of the start

(=26) of the structure. - not allowed in Unicode programs. -

NOt activatiing..

Read only

0 Likes
1,149

any issue in using direct field names in write

write: / i_mard-MATNR , i_mard-WERKS ,i_mard-LGORT , i_mard-LABST .