Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Sy-Lsind

Hi,

iam executing the following program.

TYPES:

BEGIN OF TY_KNA1,

KUNNR TYPE KNA1-KUNNR,

LAND1 TYPE KNA1-LAND1,

NAME1 TYPE KNA1-NAME1,

ORT01 TYPE KNA1-ORT01,

END OF TY_KNA1,

BEGIN OF TY_VBAK,

VBELN TYPE VBAK-VBELN,

AUDAT TYPE VBAK-AUDAT,

AUART TYPE VBAK-AUART,

NETWR TYPE VBAK-NETWR,

END OF TY_VBAK,

BEGIN OF TY_VBAP,

POSNR TYPE VBAP-POSNR,

MATNR TYPE VBAP-MATNR,

ARKTX TYPE VBAP-ARKTX,

NETPR TYPE VBAP-NETPR,

NETWR TYPE VBAP-NETWR,

END OF TY_VBAP.

DATA:

ST_KNA1 TYPE TY_KNA1,

IT_KNA1 TYPE TABLE OF TY_KNA1,

ST_VBAK TYPE TY_VBAK,

IT_VBAK TYPE TABLE OF TY_VBAK,

ST_VBAP TYPE TY_VBAP,

IT_VBAP TYPE TABLE OF TY_VBAP.

SELECT-OPTIONS:

SKUNNR FOR ST_KNA1-KUNNR.

START-OF-SELECTION.

PERFORM GETCUST_DATA.

IF IT_KNA1 IS NOT INITIAL.

LOOP AT IT_KNA1 INTO ST_KNA1.

WRITE:/ ST_KNA1-KUNNR,ST_KNA1-LAND1,ST_KNA1-NAME1,ST_KNA1-ORT01.

ENDLOOP.

ENDIF.

TOP-OF-PAGE.

WRITE:/1'CUSTOMER NO',12'CUSTOMER NAME',42'CITY',62'COUNTRY'.

AT LINE-SELECTION.

<b>CASE SY-LSIND.

WHEN 1.

WRITE:/ 'READY TO DISPLAY SALES DETAILS'.</b>

ENDCASE.

Here when 1 . I have to get the above message.

Else i want to write the statement, no sales details.

how to write that else condition here.

Tags:
Former Member
replied

Hi..

This is the code .. check the Changes in BOLD

TYPES:

BEGIN OF TY_KNA1,

KUNNR TYPE KNA1-KUNNR,

LAND1 TYPE KNA1-LAND1,

NAME1 TYPE KNA1-NAME1,

ORT01 TYPE KNA1-ORT01,

END OF TY_KNA1,

BEGIN OF TY_VBAK,

VBELN TYPE VBAK-VBELN,

AUDAT TYPE VBAK-AUDAT,

AUART TYPE VBAK-AUART,

NETWR TYPE VBAK-NETWR,

END OF TY_VBAK,

BEGIN OF TY_VBAP,

POSNR TYPE VBAP-POSNR,

MATNR TYPE VBAP-MATNR,

ARKTX TYPE VBAP-ARKTX,

NETPR TYPE VBAP-NETPR,

NETWR TYPE VBAP-NETWR,

END OF TY_VBAP.

DATA:

ST_KNA1 TYPE TY_KNA1,

IT_KNA1 TYPE TABLE OF TY_KNA1,

ST_VBAK TYPE TY_VBAK,

IT_VBAK TYPE TABLE OF TY_VBAK,

ST_VBAP TYPE TY_VBAP,

IT_VBAP TYPE TABLE OF TY_VBAP.

SELECT-OPTIONS:

SKUNNR FOR ST_KNA1-KUNNR.

START-OF-SELECTION.

PERFORM GETCUST_DATA.

IF IT_KNA1 IS NOT INITIAL.

LOOP AT IT_KNA1 INTO ST_KNA1.

WRITE:/ ST_KNA1-KUNNR,

ST_KNA1-LAND1,

ST_KNA1-NAME1,

ST_KNA1-ORT01.

<b>HIDE ST_KNA1-KUNNR.</b>

ENDLOOP.

<b>CLEAR: ST_KNA1.</b>

ENDIF.

TOP-OF-PAGE.

WRITE:/1'CUSTOMER NO',12'CUSTOMER NAME',42'CITY',62'COUNTRY'.

AT LINE-SELECTION.

CASE SY-LSIND.

<b>WHEN 1.

IF ST_KNA1-KUNNR IS NOT INITIAL.

SELECT VBELN AUDAT AUART NETWR FROM VBAK

INTO TABLE IT_VBAK

WHERE KUNNR = ST_KNA1-KUNNR.

IF SY-SUBRC = 0.

WRITE:/ 'READY TO DISPLAY SALES DETAILS'.

ELSE.

WRITE:/ 'NO SALES DATA FOUND'.

ENDIF.

ENDCASE.</b>

<b>Reward if Helpful</b>

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question