	SUBROUTINE BUILD_LINE( LINE, LINE_LTH, BUILD_QUALS, QUAL_VALUES,
     &				QUAL_TYPE)
C
C            Subroutine to build the qualifiers on a SUBMIT line.
C
	INCLUDE 'PERP.INC'
	CHARACTER LINE*512, QUAL_TYPE*1
	INTEGER	      LINE_LTH, VAL_LTH
	INTEGER       BUILD_QUALS(QUAL_COUNT)
C
	LINE = ' '
        VAL_LTH = 2
C
	IF (QUAL_TYPE .EQ. 'G') THEN
	DO I = 1, QUAL_COUNT
C   
C
	  IF (BUILD_QUALS(I) .EQ. USED_EXPLICITLY) THEN
	    LINE (LINE_LTH + 1 : LINE_LTH + 1) = '/'
	    LINE (LINE_LTH + 2 : LINE_LTH + QUAL_LTH(I) + 2)
     *					= QUALS (I) (:QUAL_LTH(I))
	    LINE_LTH = LINE_LTH + QUAL_LTH(I) + 1
C
C                     if qualifier needs a value
C
	    IF (QUAL_VALUE(I)) THEN
	      LINE (LINE_LTH + 1: LINE_LTH + 1) = '='
	      ICODE = STR$TRIM (QUAL_VALUES(I), QUAL_VALUES(I), VAL_LTH)
	      LINE (LINE_LTH + 2 : LINE_LTH + VAL_LTH + 2) =
     *						QUAL_VALUES(I)(:VAL_LTH)
	      LINE_LTH = LINE_LTH + VAL_LTH + 1
	    ENDIF
C
C                if used negated then add "NO"
C
          ELSE
	  IF (BUILD_QUALS(I) .EQ. USED_NEGATED) THEN
              LINE (LINE_LTH + 1 : LINE_LTH + 3) = '/NO'
              LINE (LINE_LTH + 4 : LINE_LTH + QUAL_LTH(I) + 4)
     *					= QUALS (I) (:QUAL_LTH(I))
              LINE_LTH = LINE_LTH + QUAL_LTH(I) + 3
            ENDIF
	  ENDIF
C
	ENDDO
	ENDIF

	IF (QUAL_TYPE .EQ. 'L') THEN
	DO I = 1, QUAL_COUNT
C   
C
	  IF (BUILD_QUALS(I) .EQ. USED_LOC_EX) THEN
	    LINE (LINE_LTH + 1 : LINE_LTH + 1) = '/'
	    LINE (LINE_LTH + 2 : LINE_LTH + QUAL_LTH(I) + 2)
     *					= QUALS (I) (:QUAL_LTH(I))
	    LINE_LTH = LINE_LTH + QUAL_LTH(I) + 1
C
C                     if qualifier needs a value
C
	    IF (QUAL_VALUE(I)) THEN
	      LINE (LINE_LTH + 1: LINE_LTH + 1) = '='
	      ICODE = STR$TRIM (QUAL_VALUES(I), QUAL_VALUES(I), VAL_LTH)
	      LINE (LINE_LTH + 2 : LINE_LTH + VAL_LTH + 2) =
     *						QUAL_VALUES(I)(:VAL_LTH)
	      LINE_LTH = LINE_LTH + VAL_LTH + 1
	    ENDIF
C
C                if used negated then add "NO"
C
          ELSE
	  IF (BUILD_QUALS(I) .EQ. USED_LOC_NEG) THEN
              LINE (LINE_LTH + 1 : LINE_LTH + 3) = '/NO'
              LINE (LINE_LTH + 4 : LINE_LTH + QUAL_LTH(I) + 4)
     *					= QUALS (I) (:QUAL_LTH(I))
              LINE_LTH = LINE_LTH + QUAL_LTH(I) + 3
            ENDIF
	  ENDIF
C
	ENDDO
	ENDIF

	RETURN
        END
