‎2007 Jun 05 6:53 AM
Hi Experts,
plz any one tell me how i can show the coloumn output in row .
actually this report is for BOM and for a specific component there are at most 8 BOMs so there will be atmost 8 entries in a coloumn and i wanna to show that entries in the form of single row for that specific component.
if any body did it b4 for any module plz give me the code.
thanks in advance.
regards
vijay dwivedi
rewards will be sure for each helpfull answer*
‎2007 Jun 05 7:02 AM
You can make an Itab with 8 fields and then pass the entries that you have in your specific component column to each of the 8 fields.
Right now you have 1 column and 8 rows.
In itab you will have 8 columns(fields) and 1 row.
that one row (structure of itab) will have 8 fields.
data: begin of itab,
<field1>,
. .
<field8>,
end of itab.
then move each column entry into itab-field1, itab-field2....etc.
‎2007 Jun 05 6:58 AM
Hi,
Check this sample code..
DATA: ITAB(10) OCCURS 0 WITH HEADER LINE.
DATA: V_MOD TYPE I.
ITAB = '11'. APPEND ITAB.
ITAB = '12'. APPEND ITAB.
ITAB = '13'. APPEND ITAB.
ITAB = '14'. APPEND ITAB.
ITAB = '21'. APPEND ITAB.
ITAB = '22'. APPEND ITAB.
ITAB = '23'. APPEND ITAB.
ITAB = '24'. APPEND ITAB.
* Display the records.
LOOP AT ITAB.
V_MOD = SY-TABIX MOD 4.
IF V_MOD = 0.
* New line
WRITE: / ITAB.
Else.
* same line
WRITE: ITAB.
ENDIF.
ENDLOOP.
Thanks
Naren
‎2007 Jun 05 6:59 AM
You can use the PIVOT Table in the excel to do such requirement unless they do need any validations to be done based on tables.
Regards
Gopi
‎2007 Jun 05 6:59 AM
Hi Vijay ,
Is the output in report form , if it is the you can use the AT NEW command to check if a new component is being considered or not , if it is a new component the start printing in a new line else continue with the same line.
Hope this helps.
Regards
Arun
‎2007 Jun 05 7:02 AM
You can make an Itab with 8 fields and then pass the entries that you have in your specific component column to each of the 8 fields.
Right now you have 1 column and 8 rows.
In itab you will have 8 columns(fields) and 1 row.
that one row (structure of itab) will have 8 fields.
data: begin of itab,
<field1>,
. .
<field8>,
end of itab.
then move each column entry into itab-field1, itab-field2....etc.
‎2007 Jun 05 7:08 AM
Hi,
actually my problem is different i want only one column fields into row and
my requirements is that i wanna to print all alternative bom that is associated with a component and that is coming in a coloumn should be print in row under headings altbom1 altbom2 and so on.
i m giving my code this is working please suggest me the solution.
REPORT ZQMR_MIXDESIGN
NO STANDARD PAGE HEADING
LINE-SIZE 255 LINE-COUNT 65.
----
DECLARATION FOR TABLE
----
TABLES: MAST,STPO,MAKT,STKO.
----
Type-pools
----
Type pools for ALV display
TYPE-POOLS: SLIS.
----
Global variables
----
data: G_REPID LIKE SY-REPID,
G_EVENTS TYPE SLIS_T_EVENT,
G_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
G_EXIT_CAUSED_BY_CALLER,
G_EXIT_CAUSED_BY_USER TYPE SLIS_EXIT_BY_USER,
G_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
*g_variant like disvariant.
*G_SAVE.
----
Declaration for Constants
----
CONSTANTS : C_X TYPE C VALUE 'X', " Flag
C_C TYPE C VALUE 'C', " Flag
C_L TYPE C VALUE 'L', " Flag
C_A TYPE C VALUE 'A', " Line Type
C_H TYPE C VALUE 'H', " Dr/Cr
C_S TYPE C VALUE 'S'. " Line Type
----
Declaration of Internal Tables
----
DATA: BEGIN OF T_MAST OCCURS 0,
MATNR LIKE MAST-MATNR,
WERKS LIKE MAST-WERKS,
STLAN LIKE MAST-STLAN,
STLNR LIKE MAST-STLNR,
STLAL LIKE MAST-STLAL,
ANDAT LIKE MAST-ANDAT,
END OF T_MAST.
*DATA: T_MAST LIKE MAST OCCURS 0 WITH HEADER LINE.
Internal Table for STPO Table data
DATA: BEGIN OF T_STPO OCCURS 0,
STLTY LIKE STPO-STLTY,
STLNR LIKE STPO-STLNR,
ANDAT LIKE STPO-ANDAT,
IDNRK LIKE STPO-IDNRK,
MEINS LIKE STPO-MEINS,
MENGE LIKE STPO-MENGE,
MENGE1 LIKE STPO-MENGE,
MENGE1 LIKE STPO-MENGE,
MENGE1 LIKE STPO-MENGE,
END OF T_STPO.
DATA: BEGIN OF T_MAKT OCCURS 0,
MATNR LIKE MAKT-MATNR,
MAKTX LIKE MAKT-MAKTX,
END OF T_MAKT.
*DATA: BEGIN OF T_STKO OCCURS 0,
STLTY LIKE STKO-STLTY,
STLNR LIKE STKO-STLNR,
STKTX
DATA: BEGIN OF T_FINAL OCCURS 0,
IDNRK LIKE STPO-IDNRK,
MAKTX LIKE MAKT-MAKTX,
MEINS LIKE STPO-MEINS,
MENGE1 LIKE STPO-MENGE,
MENGE2 LIKE STPO-MENGE,
MENGE3 LIKE STPO-MENGE,
MENGE4 LIKE STPO-MENGE,
MENGE5 LIKE STPO-MENGE,
MENGE6 LIKE STPO-MENGE,
MENGE7 LIKE STPO-MENGE,
MENGE8 LIKE STPO-MENGE,
END OF T_FINAL.
* Internal table to hold field catgory data
DATA: I_FLDCAT TYPE SLIS_T_FIELDCAT_ALV. " Table - field catgory
Internal table to hold Sort/Subtotals criteria data
DATA: I_SORT TYPE SLIS_T_SORTINFO_ALV. " Table - sort/Subtotals
----
Structure
----
DATA: X_LAYOUT TYPE SLIS_LAYOUT_ALV, " Structure-layout
X_FLDCAT LIKE LINE OF I_FLDCAT, " Structure-field catagory
X_SORT LIKE LINE OF I_SORT. " Structure-Sort/Subtotals
----
Selection screen
----
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-050.
PARAMETERS: MATNR LIKE MAST-MATNR OBLIGATORY,
WERKS LIKE MAST-WERKS OBLIGATORY,
STLAN LIKE MAST-STLAN.
SELECT-OPTIONS:
STLAL FOR MAST-STLAL.
SELECTION-SCREEN : END OF BLOCK B1.
----
Initialization
----
INITIALIZATION.
g_repid = sy-repid.
perform layout_init using x_layout.
perform eventtab_build using g_events[].
g_save = 'A'.
----
At selection screen
----
AT SELECTION-SCREEN.
Validation of Selection Screen Fields
PERFORM VALIDATE_SCREEN.
----
Start of selection
----
START-OF-SELECTION.
Read Data from Database Tables
PERFORM READ_DATA.
----
End of selection
----
END-OF-SELECTION.
Build layout report layout.
PERFORM populate_layout_stucture.
Perform build_field_catalog and Sort Table
PERFORM BUILD_FIELD_CATALOG.
PERFORM BUILD_SORT_TOTALS.
List Header for Top-Of-Page
PERFORM COMMENT_BUILD USING G_LIST_TOP_OF_PAGE[].
Call list viewer function module
PERFORM CALL_LIST_VIEWER .
****************Form - Routines**************************************
----
Form : layout_init
Description : Form to Build layout for list display
----
form layout_init using rs_layout type slis_layout_alv.
rs_layout-detail_popup = c_x.
endform. "layout_init
----
Form : Eventtab_build
Description : Registration of events to happen during list display
----
FORM EVENTTAB_BUILD USING RT_EVENTS TYPE SLIS_T_EVENT.
Registration of events to happen during list display
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = rt_events.
read table rt_events with key name = slis_ev_top_of_page
into ls_event.
if sy-subrc = 0.
move g_top_of_page to ls_event-form.
append ls_event to rt_events.
endif.
endform. "eventtab_build
----
Form : top_of_page
----
*
form TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = g_list_top_of_page.
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
.
endform. "top_of_page
----
Form validate_screen
----
Validation of Selection Screen fields
----
form VALIDATE_SCREEN.
Validation of Session Start Date
CLEAR MAST.
IF NOT MATNR IS INITIAL.
SELECT SINGLE MATNR
INTO MAST-MATNR
FROM MAST
WHERE MATNR EQ MATNR.
IF SY-SUBRC <> 0.
MESSAGE 'Enter Valid Material Number' type 'E'.
ENDIF.
ENDIF.
Validation of Plant code
CLEAR MAST.
IF NOT WERKS IS INITIAL.
SELECT SINGLE WERKS
INTO MAST-WERKS
FROM MAST
WHERE WERKS EQ WERKS.
IF SY-SUBRC <> 0.
MESSAGE 'Enter Valid Plant' TYPE 'E'.
ENDIF.
ENDIF.
CLEAR MAST.
IF NOT STLAN IS INITIAL.
SELECT SINGLE STLAN
INTO MAST-STLAN
FROM MAST
WHERE STLAN EQ STLAN.
IF SY-SUBRC <> 0.
MESSAGE 'Enter Valid Usage' TYPE 'E'.
ENDIF.
endif.
CLEAR MAST.
IF NOT STLAL IS INITIAL.
SELECT STLAL
INTO MAST-STLAL
FROM MAST
WHERE STLAL IN STLAL.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE 'Enter Valid Alternative BOM' TYPE 'E'.
ENDIF.
ENDIF.
endform. "validate_screen
&----
*& Form read_data
&----
Read the Data from the database Tables
----
form read_data.
Selection Screen
CLEAR T_MAST.
REFRESH T_MAST.
SELECT MATNR WERKS STLAN STLNR STLAL ANDAT
INTO CORRESPONDING FIELDS OF TABLE T_MAST
FROM MAST
WHERE MATNR = MATNR
AND WERKS = WERKS
and STLAN = STLAN
AND STLAL IN STLAL.
if sy-subrc <> 0.
message 'No data found' type 'I'.
stop.
endif.
SORT T_MAST BY MATNR WERKS STLAN STLAL ANDAT.
IF NOT T_MAST[] IS INITIAL.
CLEAR T_STPO.
REFRESH T_STPO.
SELECT
STLTY
STLNR
ANDAT
IDNRK
MEINS
MENGE
INTO TABLE T_STPO
FROM STPO
FOR ALL ENTRIES IN T_MAST
WHERE STLNR = T_MAST-STLNR.
ENDIF.
SORT T_STPO BY STLTY STLNR ANDAT IDNRK.
IF NOT T_MAST[] IS INITIAL.
CLEAR T_MAKT.
REFRESH T_MAKT.
SELECT MATNR MAKTX INTO
TABLE T_MAKT
FROM MAKT
FOR ALL ENTRIES IN T_MAST
WHERE MATNR = T_MAST-MATNR.
ENDIF.
LOOP AT T_MAST .
READ TABLE T_STPO WITH KEY STLNR = T_MAST-STLNR
ANDAT = T_MAST-ANDAT BINARY SEARCH.
IF SY-SUBRC = 0.
T_FINAL-IDNRK = T_STPO-IDNRK.
T_FINAL-MEINS = T_STPO-MEINS.
ENDIF.
READ TABLE T_MAKT WITH KEY MATNR = T_MAST-MATNR BINARY SEARCH.
IF SY-SUBRC = 0.
T_FINAL-MAKTX = T_MAKT-MAKTX.
ENDIF.
DATA: W_STPO LIKE STPO.
SELECT SINGLE * FROM STPO INTO W_STPO WHERE
IDNRK = STPO-IDNRK.
IF SY-SUBRC = 0.
T_FINAL-MENGE1 = W_STPO-MENGE.
ENDIF.
append t_final.
clear t_final.
ENDLOOP.
LOOP AT T_STPO INTO W_STPO.
endform. "Read Data
----
Form : populate_layout_stucture
Description : Populating the layout structure
----
form populate_layout_stucture.
clear x_layout .
Layout properties
x_layout-zebra = c_x.
x_layout-detail_popup = c_x.
x_layout-detail_initial_lines = c_x.
x_layout-colwidth_optimize = c_x.
endform. " populate_layout_stucture
----
Form : build_field_catalog
Description : Building the field catalog data
----
form build_field_catalog.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = g_repid
I_INTERNAL_TABNAME = 'T_FINAL'
I_INCLNAME = g_repid
CHANGING
CT_FIELDCAT = i_fldcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Getting the Header text for the coloums
loop at i_fldcat into x_fldcat where
fieldname = 'IDNRK' or
fieldname = 'MAKTX' or
fieldname = 'MEINS' or
fieldname = 'MENGE1' or
fieldname = 'MENGE2' or
fieldname = 'MENGE3' or
fieldname = 'MENGE4' OR
fieldname = 'MENGE5' or
fieldname = 'MENGE6' or
fieldname = 'MENGE7' or
fieldname = 'MENGE8'.
if x_fldcat-fieldname = 'IDNRK'.
x_fldcat-seltext_l = 'COMPONENT'.
x_fldcat-seltext_m = 'COMPONENT'.
x_fldcat-seltext_s = 'COMPONENT'.
x_fldcat-reptext_ddic = 'COMPONENT'.
x_fldcat-inttype = c_c.
endif.
if x_fldcat-fieldname = 'MAKTX'.
x_fldcat-seltext_l = 'COMPONENT DESCRIPTION'.
x_fldcat-seltext_m = 'COMPONENT DESCRIPTION'.
x_fldcat-seltext_s = 'COMPONENT DESCRIPTION'.
x_fldcat-reptext_ddic = 'COMPONENT DESCRIPTION'.
x_fldcat-inttype = c_c.
endif.
if x_fldcat-fieldname = 'MEINS'.
x_fldcat-seltext_l = 'UOM'.
x_fldcat-seltext_m = 'UOM'.
x_fldcat-seltext_s = 'UOM'.
x_fldcat-reptext_ddic = 'UOM'.
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MENGE1'.
x_fldcat-seltext_l = 'ALT BOM1'.
x_fldcat-seltext_m = 'ALT BOM1'.
x_fldcat-seltext_s = 'ALT BOM1'.
x_fldcat-reptext_ddic = 'ALT BOM1'.
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MENGE2'.
x_fldcat-seltext_l = 'ALT BOM2'.
x_fldcat-seltext_m = 'ALT BOM2'.
x_fldcat-seltext_s = 'ALT BOM2'.
x_fldcat-reptext_ddic = 'ALT BOM2'.
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MENGE3'.
x_fldcat-seltext_l = 'ALT BOM3'.
x_fldcat-seltext_m = 'ALT BOM3'.
x_fldcat-seltext_s = 'ALT BOM3'.
x_fldcat-reptext_ddic = 'ALT BOM3'.
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MENGE4'.
x_fldcat-seltext_l = 'ALT BOM4'.
x_fldcat-seltext_m = 'ALT BOM4'.
x_fldcat-seltext_s = 'ALT BOM4'.
x_fldcat-reptext_ddic = 'ALT BOM4'.
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MENGE5'.
x_fldcat-seltext_l = 'ALT BOM5'.
x_fldcat-seltext_m = 'ALT BOM5'.
x_fldcat-seltext_s = 'ALT BOM5'.
x_fldcat-reptext_ddic = 'ALT BOM5'.
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MENGE6'.
x_fldcat-seltext_l = 'ALT BOM6'.
x_fldcat-seltext_m = 'ALT BOM6'.
x_fldcat-seltext_s = 'ALT BOM6'.
x_fldcat-reptext_ddic = 'ALT BOM6'.
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MENGE7'.
x_fldcat-seltext_l = 'ALT BOM7'.
x_fldcat-seltext_m = 'ALT BOM7'.
x_fldcat-seltext_s = 'ALT BOM7'.
x_fldcat-reptext_ddic = 'ALT BOM7'.
x_fldcat-ddictxt = c_l.
endif.
if x_fldcat-fieldname = 'MENGE8'.
x_fldcat-seltext_l = 'ALT BOM8'.
x_fldcat-seltext_m = 'ALT BOM8'.
x_fldcat-seltext_s = 'ALT BOM8'.
x_fldcat-reptext_ddic = 'ALT BOM8'.
x_fldcat-ddictxt = c_l.
endif.
modify i_fldcat from x_fldcat index sy-tabix.
endloop.
endform. " build_field_catalog
----
Form : build_sort_totals
Description : Building the Criteria for Sort/Subtotals
----
form build_sort_totals.
x_sort-fieldname = 'IDNRK'.
x_sort-tabname = 'T_FINAL'.
x_sort-spos = 1.
x_sort-up = c_x.
*x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MAKTX'.
x_sort-tabname = 'T_FINAL'.
x_sort-spos = 2.
x_sort-up = c_x.
*x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MEINS'.
x_sort-tabname = 'T_FINAL'.
x_sort-spos = 3.
x_sort-up = c_x.
*x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MENGE1'.
x_sort-tabname = 'T_FINAL'.
x_sort-spos = 4.
x_sort-up = c_x.
*x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MENGE2'.
x_sort-tabname = 'T_FINAL'.
x_sort-spos = 5.
x_sort-up = c_x.
*x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MENGE3'.
x_sort-tabname = 'T_FINAL'.
x_sort-spos = 6.
x_sort-up = c_x.
*x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MENGE4'.
x_sort-tabname = 'T_FINAL'.
x_sort-spos = 7.
x_sort-up = c_x.
*x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MENGE5'.
x_sort-tabname = 'T_FINAL'.
x_sort-spos = 8.
x_sort-up = c_x.
*x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MENGE6'.
x_sort-tabname = 'T_FINAL'.
x_sort-spos = 9.
x_sort-up = c_x.
*x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MENGE7'.
x_sort-tabname = 'T_FINAL'.
x_sort-spos = 10.
x_sort-up = c_x.
*x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
x_sort-fieldname = 'MENGE8'.
x_sort-tabname = 'T_FINAL'.
x_sort-spos = 11.
x_sort-up = c_x.
*x_sort-subtot = c_x.
append x_sort to i_sort.
clear x_sort.
endform. " build_sort_totals
----
Form : comment_build
Description : This form is used to display the Report Header(ALV)
----
*
form comment_build using lt_top_of_page type
slis_t_listheader.
data: l_line type slis_listheader,
l_heading1 like rs38m-repti.
clear l_line.
l_heading1 = 'Fuel Consumption Report'.
g_repid = sy-repid.
l_line-typ = c_h.
move l_heading1 to l_line-info.
append l_line to lt_top_of_page.
DATA: GD_DATE(10), HD_DATE(10).
*
l_line-TYP = c_s.
IF date-LOW IS NOT INITIAL AND date-HIGH IS NOT INITIAL.
WRITE date-LOW TO GD_DATE DD/MM/YYYY.
WRITE date-HIGH TO HD_DATE DD/MM/YYYY.
CONCATENATE 'Date From :' GD_DATE 'to' HD_DATE INTO l_line-INFO
SEPARATED BY SPACE.
append l_line to lt_top_of_page.
endif.
CLEAR: l_line, GD_DATE, HD_DATE .
*
l_line-TYP = c_s.
concatenate ' Plant : ' Plant-low
' To: ' Plant-high into l_line-info.
append l_line to lt_top_of_page.
endform. "comment_build
----
Form : call_list_viewer
Description : This form is used to display the grid through ALV
----
form call_list_viewer.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = g_repid
IS_LAYOUT = x_layout
IT_FIELDCAT = i_fldcat[]
IT_SORT = i_sort[]
I_DEFAULT = c_x
I_SAVE = g_save
IT_EVENTS = g_events[]
IMPORTING
E_EXIT_CAUSED_BY_CALLER = g_exit_caused_by_caller
ES_EXIT_CAUSED_BY_USER = g_exit_caused_by_user
TABLES
T_OUTTAB = T_final
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
write: / 'Problem in calling the ALV report'(042).
ENDIF.
endform. " call_list_viewer
‎2007 Jun 05 8:06 AM
Hi ,
just replicated the code for ur scenario.
See if this works for u .
report zex6.
DATA: begin of ITAB OCCURS 0,
a(10),
b(10),
end of itab.
data : g_flag.
data n type i.
ITAB-a = 'PARENT1'. ITAB-B = 'CHILD1'. . APPEND ITAB.
ITAB-B = 'CHILD2'.APPEND ITAB.
ITAB-B = 'CHILD3'.APPEND ITAB.
ITAB-B = 'CHILD4'.APPEND ITAB.
ITAB-B = 'CHILD5'.APPEND ITAB.
ITAB-B = 'CHILD6'.APPEND ITAB.
ITAB-B = 'CHILD7'.APPEND ITAB.
ITAB-B = 'CHILD8'.APPEND ITAB.
ITAB-a = 'PARENT2'. ITAB-B = 'CHILD21'. . APPEND ITAB.
ITAB-B = 'CHILD22'.APPEND ITAB.
ITAB-B = 'CHILD23'.APPEND ITAB.
ITAB-B = 'CHILD24'.APPEND ITAB.
*ur itab structure .
loop at itab. "ur itab format
write:/ itab-a , itab-b.
endloop.
**making columns to rows.
skip 2.
write:/ 'making columns to rows'.
sort itab by a b.
loop at itab.
at new a.
g_flag = 'X'.
write:/ itab-a.
endat.if g_flag = 'X'.
n = n + 10.
write at n itab-b.
endif.
at end of a .
clear: g_flag, n.
endat.
endloop.Regards,
Vijay.