Skip to Content

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

SAP SCRIPTS

Hi all,

i had given a task of displaying records according to inspection lot number i had created a form n write the coding as below but the probelem is that i m getting continious out put while i want when the new inspection lot number comes it start from a diffrent page i try all the possible combination in the loop but not getting it plz go through he code

REPORT z_hs_1.

TABLES: qals,qamv,qmtt,qapo,plko,mara,jest,aufk,afko.

  • SELECTION SCREEN .

SELECT-OPTIONS:

s_inspno FOR qals-prueflos.

  • TABLE FOR THE HEADER WINDOW.

TYPES : BEGIN OF ty_qals,

prueflos TYPE qals-prueflos,

werk TYPE qals-werk,

art TYPE qals-art,

plnnr TYPE qals-plnnr,

charg_d TYPE qals-charg,

lichn TYPE qals-lichn,

ebeln TYPE qals-ebeln,

lifnr TYPE qals-lifnr,

selmatnr TYPE qals-matnr,

ktextmat TYPE qals-ktextmat,

gesstichpr TYPE qals-gesstichpr,

name1 TYPE lfa1-name1,

vagrp TYPE plko-vagrp,

ktext TYPE plko-vagrp,

plnnr_alt TYPE plko-plnnr_alt,

datuv TYPE plko-datuv,

END OF ty_qals.

TYPES: BEGIN OF ty_lfa1,

lifnr TYPE lfa1-lifnr,

name1 TYPE lfa1-name1,

END OF ty_lfa1.

TYPES: BEGIN OF ty_plko,

plnnr TYPE plko-plnnr,

vagrp TYPE plko-vagrp,

ktext TYPE plko-vagrp,

plnnr_alt TYPE plko-plnnr_alt,

datuv TYPE plko-datuv,

END OF ty_plko.

  • TABLE FOR THE MAIN WINDOW.

TYPES: BEGIN OF ty_qamv,

prueflos TYPE qamv-prueflos,

merknr TYPE qamv-merknr,

physprobe TYPE qamv-physprobe,

satzstatus TYPE qamv-satzstatus,

pmethode TYPE qamv-pmethode,

kurztext TYPE qamv-kurztext,

toleranzob TYPE qamv-toleranzob,

toleranzun TYPE qamv-toleranzun,

mengeneinh TYPE qamv-mengeneinh,

END OF ty_qamv.

  • CONSTANT DECLERATION.

CONSTANTS:

c_len VALUE 4,

c_deci VALUE 2,

c_mainheader(20) VALUE 'MAIN_HEADER',

c_function(8) VALUE 'SET',

c_type(8) VALUE 'BODY',

c_winhead(20) VALUE 'HEADER',

c_bodyhead(20) VALUE 'BODY_HEADER ',

c_winmain(10) VALUE 'MAIN',

c_bodymethod(15) VALUE 'BODY_METHOD',

c_bodycharac(20) VALUE 'BODY_CHARACTERISTIC ',

c_textheader(20) VALUE 'TEXT_HEADER '.

DATA: i_qals TYPE STANDARD TABLE OF ty_qals,

w_qals TYPE ty_qals.

DATA: i_lfa1 TYPE STANDARD TABLE OF ty_lfa1,

w_lfa1 TYPE ty_lfa1.

DATA: i_qamv TYPE STANDARD TABLE OF ty_qamv,

w_qamv TYPE ty_qamv.

DATA: i_plko TYPE STANDARD TABLE OF ty_plko,

w_plko TYPE ty_plko.

DATA: l_r TYPE char1,

l_s TYPE char1.

DATA: v_rqlow TYPE p LENGTH c_len DECIMALS c_deci,

v_rqhigh TYPE p LENGTH c_len DECIMALS c_deci.

*END OF INTERNAL TABLE DECLARATION.

  • FETCHING RECORDS FOR THE HEADER WINDOW.

SELECT prueflos

werk

art

plnnr

charg

lichn

ebeln

lifnr

selmatnr

ktextmat

gesstichpr

FROM qals

INTO TABLE i_qals

WHERE prueflos IN s_inspno .

IF sy-subrc <> 0.

ENDIF.

SELECT lifnr

name1

FROM lfa1

INTO TABLE i_lfa1.

IF sy-subrc <> 0.

ENDIF.

SELECT plnnr

vagrp

ktext

plnnr_alt

datuv

FROM plko

INTO TABLE i_plko.

  • WHERE plnnr = w_qals-plnnr.

IF sy-subrc <> 0.

ENDIF.

  • FETCHING RECORDS FOR THE MAIN WINDOW.

SELECT

prueflos

merknr

physprobe

satzstatus

pmethode

kurztext

toleranzob

toleranzun

mengeneinh

FROM qamv

INTO TABLE i_qamv

WHERE prueflos IN s_inspno.

IF sy-subrc <> 0.

ENDIF.

  • CALLING THE REQUIRED FUNCTION.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

application = 'TX'

device = 'PRINTER'

form = 'Z_HS_INSP'

language = sy-langu.

IF sy-subrc <> 0.

ENDIF.

CALL FUNCTION 'START_FORM'

EXPORTING

form = 'Z_HS_INSP'.

IF sy-subrc <> 0.

ENDIF.

  • LOOP FOR THE HEADER .

LOOP AT i_qals INTO w_qals.

READ TABLE i_lfa1 INTO w_lfa1

WITH KEY lifnr = w_qals-lifnr.

w_qals-name1 = w_lfa1-name1.

READ TABLE i_plko INTO w_plko

WITH KEY plnnr = w_qals-plnnr.

w_qals-vagrp = w_plko-vagrp.

w_qals-ktext = w_plko-ktext.

w_qals-plnnr_alt = w_plko-plnnr_alt.

w_qals-datuv = w_plko-datuv.

MODIFY i_qals FROM w_qals INDEX 1

TRANSPORTING name1 vagrp ktext plnnr_alt datuv.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = c_mainheader

function = c_function

type = c_type

window = c_winhead.

IF sy-subrc <> 0.

ENDIF.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = c_textheader

function = c_function

type = c_type

window = c_winmain.

IF sy-subrc <> 0.

ENDIF.

LOOP AT i_qamv INTO w_qamv .

IF w_qamv-satzstatus = '1'.

l_r = 'Y'.

ELSE.

l_r = 'N'.

ENDIF.

IF w_qamv-satzstatus = '4'.

l_s = 'Y'.

ELSE.

l_s = 'N'.

ENDIF.

v_rqlow = w_qamv-toleranzun.

v_rqhigh = w_qamv-toleranzob.

  • FUNCTION CALL FOR THE MAIN WINDOW .

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = c_bodyhead

function = c_function

type = c_type

window = c_winmain.

IF sy-subrc <> 0.

ENDIF.

ENDLOOP.

ENDLOOP.

CALL FUNCTION 'END_FORM'.

IF sy-subrc <> 0.

ENDIF.

CALL FUNCTION 'CLOSE_FORM'.

IF sy-subrc <> 0.

ENDIF.

thanks

himanshu sharma

Former Member
Not what you were looking for? View more on this topic or Ask a question